How to tell if enter is pressed in textfield?

BlitzPlus Forums/BlitzPlus Programming/How to tell if enter is pressed in textfield?

sswift(Posted 2005) [#1]
Does anyone know how to tell if the user pressed enter, or is holding shift while a textfield is active?

I want a user to be able to type a number into a textfield and recalculate the final image if they press enter at that time.

And I need to know if shift is being held down because if the textfield is active and the user clicks on the preview pane with the mouse, then the preview pane should zoom in.

Right now I have the shift thing sort of working by making the window the actgive gadget if any gadget other than the textfields are clicked, and that works okay, but it's kind of kludgy to have to check to see if any gadget other than a textfield is clicked and reset the window to being active just to see if the user is holding shift.


skidracer(Posted 2005) [#2]
to answer the original question you get a gadgethit event eventid()=$401 and the eventdata()=13

not sure if this is documented but mouse events return modifier bits in eventz() (1 for shift)

hope this helps...


Beaker(Posted 2005) [#3]
EventZ() now (partly) documented.


sswift(Posted 2005) [#4]
AUGH!

Couldn't you guys have told me this sooner... I just spent hours researching and writing this crap:

http://www.blitzbasic.com/codearcs/codearcs.php?code=1319

And what did hours of research net me? A grand total of ONE function!

Of course if I hadn't insisted on typing out all the constant nicely for everyone it would have taken me a lot less time, but STILL!

And why didn't I think of checking for Chr$(13)? I checked for KeyHit()...

Acutally I DID think to check for Chr$(13)... When I THOUGHT about using crappy TextAreas, because I knew they must be recording enter in their strings. But I did not think that textfields would also return Chr$(13), because the strings they record don't contain them! And I didn't realise that EventData() returned the character typed into them.

BAH.


sswift(Posted 2005) [#5]
"EventZ() now (partly) documented."

No it aint!

http://www.blitzbasic.com/bpdocs/command_list_gui_cat.php?show=Events


skidracer(Posted 2005) [#6]
a simple thanks would have done


sswift(Posted 2005) [#7]
Aww, you know I'm grateful! I'm just pissed at myself for overlooking the obvious.


sswift(Posted 2005) [#8]
Hm... turns out all my work wasn't for nothing, because though I can determine if the shift key is held down while I am holding down the mouse button, I would NOT be able to turn the mouse cursor into a magnifying glass when the shift key is being held down and over my panel while my textfield still has focus!


Wiebo(Posted 2005) [#9]
ah. that's handy info. thanks all!!


Beaker(Posted 2005) [#10]
sswift - documented here:
http://www.blitzbasic.com/bpdocs/command.php?name=WaitEvent&ref=gui_cat
I can't add commands to the list, thats why I said "(partly)".


Gabriel(Posted 2006) [#11]
NM. Sorry. Searched the BlitzMax forums and I got this :/