|
Tarn GURU
Joined: 10 Oct 2000 Posts: 873 Location: USA
|
Posted: Thu Mar 17, 2005 6:43 pm
Events, keyup in particular |
I don't see the events of zApp objects listed in the docs under the section of the controls, Edit for example. I'm probably looking in the wrong place.
I'm trying to catch a keyup event on the Edit control. The event seems to accept two arguments, as I expected (if you write a sub accepting only one, you get an error message when it fires telling you that zApp tried to pass 2).
I can't figure out the type of the second argument, though. A typeof() in the script returns "Object", and unlike the Sender argument it doesn't seem to have a default property.
The example below shows a few of the tries I've made- it will give a succession of error messages as the various accesses fail (reading what's currently in the textbox succeeds, but doesn't help because I'm trying to catch the Enter key and that doesn't seem to put CRLF on the end of the text).
Mar 15 build of zApp.
-Tarn
Code: |
<window name="main">
<edit name="test"></edit>
<script>
test.text = "hello world"
sub test_OnKeyUp(Sender,whichkey)
on error resume next
msgbox "KeyUp fired",1
msgbox "current contents of textbox:" & sender,1
if err.number <> 0 then
msgbox "retrieval of text failed" & err.number,1
err.clear
end if
msgbox "whichkey?:" & whichkey,1
if err.number <> 0 then
msgbox "direct use failed",1
err.clear
end if
msgbox "whichkey?:" & cstr(whichkey),1
if err.number <> 0 then
msgbox "conversion to string failed",1
err.clear
end if
msgbox "whichkey?:" & clng(whichkey),1
if err.number <> 0 then
msgbox "conversion to long failed",1
err.clear
end if
end sub
</script>
</window>
|
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Mar 17, 2005 7:00 pm |
I haven't documented the events yet because they are greatly in flux with the changeover to the DevExpress controls.
But basically, *every* event only has two parameters. The first parameter is the object that triggered the event. The second argument is a general "Params" argument which then has subproperties dependant upon the specific event. So, without documentation of the second argument, which will be different for every event, there isn't much you'll be able to do.
In the Keyup case, take a look at the CALC.ZML demo program. It has an OnKeyDown event and you'll see it access the second argument to get the key that was pressed. The OnKeyUp event uses the same arguments. |
|
|
|
theNerd Adept
Joined: 01 Mar 2005 Posts: 277
|
Posted: Thu Mar 17, 2005 7:05 pm |
Quick answer for others who might have the same question:
Code: |
sub test_OnKeyUp(Sender,whichkey)
msgbox whichkey.key
end sub |
|
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|