GadgetFilter with Minus Key not working
BlitzMax Forums/MaxGUI Module/GadgetFilter with Minus Key not working
| ||
Hey, I have a GadgetFilter that should only allow numbers and the '-' (minus) key to be input into a textfield. Everything works, except that I can't input '-'. Here is the Filter function: Function NumberFilter:Int(event:TEvent,context:Object) If (event.data >= 48) And (event.data <= 57) Return 1 ElseIf (event.data = KEY_BACKSPACE) Or (event.data = KEY_DELETE) Or (event.data = KEY_LEFT) Or (event.data = KEY_RIGHT) Or (event.data = KEY_TAB) Or (event.data = KEY_ENTER) Or (event.data = KEY_MINUS) Return 1 EndIf Return 0 End Function I'm on OSX 10.7 btw. Last edited 2012 |
| ||
Without looking or testing.. are you sure KEY_MINUS is the same as the ascii character code (45). |
| ||
Yes, I tried it with 45 as well. |
| ||
Try thisFunction TextField1_Filter:Int( event:TEvent,context:Object ) DebugLog "TextField TextField1 filtering text input: "+Chr(Event.data)+"="+Event.Data+","+Event.Mods Select Event.ID Case EVENT_KEYDOWN If Event.Data = 45 Then Return True Case EVENT_KEYCHAR If Event.Data = 45 Then Return True If Event.Data => KEY_0 And Event.Data <= KEY_9 Then Return True End Select Return False End Function |
| ||
Pressing minus outputs this: http://www.codetable.net/decimal/65405 symbol from link;191,0 Also, when pressing Y it recognizes it as X. I've a german keyboard layout, that means it recognizes it as english? Last edited 2012 |
| ||
Aren't those codes not keyboard scancode related? For example there is no KEY_PLUS because it sits together with another key, which is then language dependent. |