has anyone an idea on “how to display a status in a textfield”?
on action theObject
if name of theObject is "status" then
tell application "Internet Connect"
set status to state of status of configuration
end tell
set content of text field "status" of tab view item "Connection" of tab view "tab" of window id 1 to status
end if
end action
This should display the status of the connection to the Textfield - but it will not do it…
on action theObject
if name of theObject is "status" then
tell application "Internet Connect"
set con_status to state of status of configuration
end tell
set content of text field "status" of tab view item "Connection" of tab view "tab" of window id 1 to con_status
end if
end action
Changing the variable from status to con_status has not resolved this issue…
on action theObject
if name of theObject is "con_status" then
tell application "Internet Connect"
set con_status to state of status of configuration 1
return 1
end tell
set content of text field "con_status" of tab view item "Connection" of tab view "tab" of window id 1 to (con_status as text)
end if
end action
configuration to configuration 1
The text field = con_status
But I am not able to see the status…
Is the syntax correct "if name of theObject is “con_status”… ?
Some questions:
How are you triggering the ‘on action’ handler? Do you have an interface element named “con_ststus” set up to trigger the handler? (ie linked to the handler in IB) How are you expecting the text field to update? The ‘on action’ handler needs an action to trigger it.
tell application "Internet Connect"
set con_status to state of status of configuration 1
return 1
end tell
set content of text field "con_status" of tab view item "Connection" of tab view "tab" of window id 1 to (con_status as text)
end awake from nib
Now I tried to let the state to wake from nib - but with no results - no state will be displayed...:/
Best Regards,
Stefan
PS: I don´t have a documentation right now, but am I correct that return 1 means to return the command every second?
on awake from nib
-- Should make text field "con_status" contain 1
set contents of text field "con_status" of tab view item "Connection" of tab view "tab" of window id 1 to (1 as text)
end awake from nib
If that works try:
on action theObject
if name of theObject is "con_status" then
tell application "Internet Connect"
set con_status to state of status of configuration 1
end tell
set contents of text field "con_status" of tab view item "Connection" of tab view "tab" of window id 1 to (con_status as text)
end if
end action
‘return’ exits the handler (‘on action’, ‘on awake from nib’, etc). ‘return 1’ only means return every second in an ‘on idle’ handler (this is a special case), in the current case it would mean exit the ‘awake from nib’ handler with a result of 1.
thanks a lot for your help! This works - the state will be presented with 0 to 8!
now I have to find out on how to present not a number but a text and how to
present the actual state (which means that the con_status should be refreshed every second)
The Code for displaying the correct status as text:
set con_status to state for status of configuration 1 as string
if con_status is "0" then
set text_status to "Disconnected"
end if
set contents for text field "con_status" of tab view item "Connection" of tab view "tab" of window id 1 to (text_status as text)
on idle theObject
tell application "Internet Connect"
set con_status to state of status of configuration 1 as string
end tell
if con_status is "0" then
set text_status to "Nicht verbunden"
else if con_status is "1" then
set text_status to "Irgendwas"
else if con_status is "2" then
set text_status to "Irgendwo"
else if con_status is "3" then
set text_status to "Irgendwann"
else if con_status is "8" then
set text_status to "Verbunden"
end if
set contents of text field "con_status" of tab view item "Connection" of tab view "tab" of window id 1 to (text_status as text)
return 1
end idle
return 1 - shows only status 2 → then it will not show more…