Textfield RETURN_KEY tweak
BlitzMax Forums/MaxGUI Module/Textfield RETURN_KEY tweak
| ||
| Hi, textfields won't register RETURN_KEY by default, but with a little tweak this is possible. Add this constant in Gadget.bmx file: const TEXTFIELD_MULTILINE = 2 ...and in win32maxguiex.bmx line 2285 right after this statement: If style&TEXTFIELD_PASSWORD Then wstyle:|ES_PASSWORD ...add this line: If style&TEXTFIELD_MULTILINE Then wstyle:|ES_MULTILINE Here is a little example:
Strict
Import maxgui.drivers
Local win:tgadget = CreateWindow("Window",200,200,300,200,Null)
Local lab:tgadget = CreateLabel("Type something and press enter:",6,40,250,23,win)
Local txt:tgadget = CreateTextField(6,70,250,23,win,TEXTFIELD_MULTILINE)
SetGadgetFilter(txt,TextFilter)
Repeat
WaitEvent()
Select EventID()
Case EVENT_WINDOWCLOSE End
EndSelect
Forever
Function TextFilter(event:TEvent,context:Object)
If Not event Then Return Null
Select event.id
Case EVENT_KEYDOWN
Select event.data
Case KEY_RETURN
Notify "You pressed RETURN_KEY"
Return False
EndSelect
EndSelect
Return True
EndFunction
-Henri |
| ||
There seems to be a little ghosting issue with this tweak, but if I comment out...Method WndProc(hwnd,msg,wp,lp) Local event:TEvent Select msg Case WM_ERASEBKGND 'Return 1...Return 1 from TWindowsTextfield-->WndProc() then everything looks normal. -Henri |
| ||
| why not just have a hidden OK button? that way its easy to sort :) |
| ||
| This is bit more precise and bit more native for those that prefer it -Henri |