Spécial ! |
Version mobile de l'aldweb Site m.aldweb.com Ni Français, ni Anglais ?Essayez donc l'un de ces drapeaux :
|
|
Météo / Spam / www |
Météo Lyon
aldweb contre le SPAM
|
|
|
|
|
|
|
- Forum - iziBasic
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257
Sujet n° 1615 |
getfocus |
le 02/07/2008 @ 13:57 par Gary
|
I am currently working on a calculator with a couple of fields to store numbers in when a number button is pressed.
I will need to get the ID of those fields to put the numbers in the correct field, but I can't use GETFOCUS in the number button because the ID will change as soon as the number button is pressed.
I tried to put something in the event handler, but it's not working.
Here is some code:
_EventsLoop: REPEAT %EVT%=WAITEVENT SELECT CASE %EVT% CASE 1 'this is the 1 button GOSUB _ONE CASE 15 '15 is an ID of a field GOSUB _FLD END SELECT UNTIL %EVT%=-1 RETURN
_FLD: A$="15" UPDATEFIELD #15,A$ RETURN
_ONE: RETURN
I figured when I touch the field ID#15 to set its focus it would go to _FLD
Is there a better way?
Thank Gary |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 1 -------- le 04/07/2008 @ 08:51 par Gary
visiteur |
I have tested GETFOCUS in couple of different pieces of code and I get the same result "0". I seems that GETFOCUS isn't working or I am coding it wrong.
Here is a sample:
First I click on the Field in question to set its focus.
Then I click the one button. _ONE: F=GETFOCUS SETFONT 2 COLOR 1 F$=STR$(F,0) GPRINT F$,60,1 RETURN
It prints a "0" to the screen.
Then I tried this
CASE 15 '15 IS A FIELD F=GETFOCUS END SELECT UNTIL %EVT%=-1 RETURN
_ONE: SETFONT 2 COLOR 1 F$=STR$(F,0) GPRINT F$,60,1 RETURN
Same result.
Am I using GETFOCUS wrong?
|
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 2 -------- le 06/07/2008 @ 03:34 par Gary
visiteur |
I worked it out last night. I added a pen down event to my event handler and went from there.
CASE 1000 GOSUB _SETUP CASE 1001 GOSUB _MENU END SELECT UNTIL %EVT%=-1 RETURN
_SETUP: G=GETFOCUS C=0 L=LEN(N$) REPEAT N$=N$+" " UNTIL L=5 RETURN
Gary |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 3 -------- le 06/07/2008 @ 17:47 par aldweb
visiteur |
Hello Gary,
GETFOCUS should return the focus of the last managed object, for example the button you just pressed.
I think to remember that fields do not return a GETFOCUS value because there is no event generated by a field in iziBasic. I would have to test a little bit further to check this...
Cheers, aldweb
|
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 4 -------- le 07/07/2008 @ 08:16 par Gary
visiteur |
I did test it and it does return a field value, but it does not return a button event.
My first attempts all return 0. No button had a value of 0, they were all 1, 2, 3...
My last setup worked and I can prove it was returning a field event. Once I started getting real events I set it up to print the value on the screen and it print all the field events, but return a 0 when a button was clicked.
My last post explanes my setup, I added a down pen event in the event handler and from there I added g=getfocus. The next thing I did to test this was to made a button start the process. Instead of the orignal purpose I made it print the result of the getfocus to the screen it print every field I had defined, but no buttons.
Thanks Gary |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 5 -------- le 11/07/2008 @ 12:54 par aldweb
visiteur |
Hello Gary,
I did test it and it does return a field value, but it does not return a button event.
You are right, this is it! GETFOCUS returns which field has the focus since fields do not send an event when they've got the blinking cursor for input, this was the purpose for creating this statement! Buttons and other objects return an event. Knowing if they have the focus or not is therefore usually not needed (and was not possible at all before Palm invented this blue ring stuff for one-handed navigation in the recent devices).
Cheers, aldweb
|
|
|
sujet actif
sujet clos
Important!
Nouveau message -
Rectifier message
Clôturer sujet
Remonter
|
|
|
|
|
|