Hi Folks,
this is maybe a stupid question, but is it possible to have more than 1 on clicked theObject handler in XCode?
Background: my onclicked theObject handler is pretty large, therefore it takes a long time after pressing a button until the result will be displayed or until the process starts…
Has anybody an idea on what I shall do?
Below is the current onClicked theObject handler…
on clicked theObject
-- Löschen des SMS Textes
if name of theObject is "sms_delete" then
set contents of text view "text" of scroll view "text" of tab view item "Outbox" of tab view "tab" of window "main" to ""
end if
-- dieser block muss immer gleich sein mit dem obersten block
set modem_check to serialport list
if modem_check contains "/dev/cu.HUAWEIMobile-Modem" then
set modem to "/dev/cu.HUAWEIMobile-Modem"
set modem_display to "Web'n'walk Box compact"
else if modem_check contains "/dev/cu.Icon Modem" then
set modem to "/dev/cu.Icon Modem"
set modem_display to "Web'n'walk Box"
end if
--serialport close modem_check
-- set idle of theObject to false
--display dialog modem_display
if name of theObject is "Connect" then
tell window "main"
set PopupButtonItem to modem_display
end tell
set theMatrixItem to title of current cell of matrix "theMatrix" of tab view item "Setting" of tab view "tab" of window "main"
if modem_display is "Web'n'walk Box compact" then
-- Check Huawei E220 gprsinternet
if (PopupButtonItem is "Web'n'walk Box compact") and (theMatrixItem is "HSDPA Internet") then
tell application "Internet Connect"
set configName to "HUAWEI Mobile"
set currentStatus to status of configuration configName
connect PPP configuration configName to telephone number "gprsinternet"
quit
end tell
set enabled of button "Connect" of tab view item "Connection" of tab view "tab" of window "main" to false
set enabled of button "Disconnect" of tab view item "Connection" of tab view "tab" of window "main" to true
end if
-- Check Huawei E220 business.gprsinternet
if (PopupButtonItem is "Web'n'walk Box compact") and (theMatrixItem is "HSDPA Business") then
tell application "Internet Connect"
set configName to "HUAWEI Mobile"
set currentStatus to status of configuration configName
connect PPP configuration configName to telephone number "business-gprsinternet"
quit
end tell
set enabled of button "Connect" of tab view item "Connection" of tab view "tab" of window "main" to false
set enabled of button "Disconnect" of tab view item "Connection" of tab view "tab" of window "main" to true
end if
else if modem_display is "Web'n'walk Box" then
-- web'n'walk box - gprsinternet
if (PopupButtonItem is "Web'n'walk Box") and (theMatrixItem is "HSDPA Internet") then
tell application "Internet Connect"
set configName to "Icon Modem"
set currentStatus to status of configuration configName
connect PPP configuration configName to telephone number "gprsinternet"
quit
end tell
set enabled of button "Connect" of tab view item "Connection" of tab view "tab" of window "main" to false
set enabled of button "Disconnect" of tab view item "Connection" of tab view "tab" of window "main" to true
end if
-- web'n'walk box - business.gprsinternet
if (PopupButtonItem is "Web'n'walk Box") and (theMatrixItem is "HSDPA Business") then
tell application "Internet Connect"
set configName to "Icon Modem"
set currentStatus to status of configuration configName
connect PPP configuration configName to telephone number "business.gprsinternet"
quit
end tell
set enabled of button "Connect" of tab view item "Connection" of tab view "tab" of window "main" to false
set enabled of button "Disconnect" of tab view item "Connection" of tab view "tab" of window "main" to true
end if
end if
end if
if name of theObject is "Disconnect" then
tell application "Internet Connect"
if modem_display is "Web'n'walk Box compact" then
set configName to "HUAWEI Mobile"
end if
if modem_display is "Web'n'walk Box" then
set configName to "Icon Modem"
end if
set currentStatus to status of configuration configName
disconnect configuration configName
end tell
set enabled of button "Connect" of tab view item "Connection" of tab view "tab" of window "main" to true
set enabled of button "Disconnect" of tab view item "Connection" of tab view "tab" of window "main" to false
end if
delay 5
set init_run to false
idle
if name of theObject is "sms_button" then
set contents of text field "sms_report" of tab view item "Outbox" of tab view "tab" of window "main" to "Nachricht wird gesendet"
set portRef to serialport open modem
-- SMS senden
---- Speicherart der SMS setzen 1 - Text
set xstr to "at+cmgf=1" & return
serialport write xstr to portRef
set content of control "pegel_send" of tab view item "Outbox" of tab view "tab" of window "main" to 2
delay 1
-- SMS Center setzen
set sms_center to "\"+43676021\""
set xstr to "at+csca=" & sms_center & return
serialport write xstr to portRef
set content of control "pegel_send" of tab view item "Outbox" of tab view "tab" of window "main" to 3
delay 1
-- Telefonnummer holen:
set theNumber to contents of text field "sms_nummer" of tab view item "Outbox" of tab view "tab" of window "main"
set quota to "\""
set sms to quota & theNumber & quota
set content of control "pegel_send" of tab view item "Outbox" of tab view "tab" of window "main" to 4
delay 1
-- Text holen
set text_sms to contents of text view "text" of scroll view "text" of tab view item "Outbox" of tab view "tab" of window "main"
set ctrl to ASCII character 26
set xstr to "at+cmgs=" & sms & return
serialport write xstr to portRef
serialport write text_sms to portRef
serialport write ctrl to portRef
set report to "SMS gesendet!"
set contents of text field "sms_report" of tab view item "Outbox" of tab view "tab" of window "main" to report
serialport close portRef
set content of control "pegel_send" of tab view item "Outbox" of tab view "tab" of window "main" to 5
delay 2
end if
end clicked
Thanks a lot for your help and support…
Best Regards,
Stefan