MaxGUI Problem
BlitzMax Forums/MaxGUI Module/MaxGUI Problem
| ||
Wanna press enter to add text to the textarea but this isn't working any advice.Global EditWindow:TGadget=CreateWindow("EditWindow",0,00,611,509,0,3) Global teaTextArea0:TGadget=CreateTextArea(9,10,459,319,EditWindow,0) SetGadgetText teaTextArea0,"" SetTextAreaColor teaTextArea0,255,255,255,1 SetTextAreaColor teaTextArea0,0,0,0,0 SetGadgetLayout teaTextArea0,1,0,1,0 Global libListBox0:TGadget=CreateListBox(481,12,109,317,EditWindow) AddGadgetItem libListBox0,"item0" SelectGadgetItem libListBox0,0 SetGadgetLayout libListBox0,1,2,1,2 Global tfdTextField0:TGadget=CreateTextField(8,336,582,20,EditWindow) SetGadgetLayout tfdTextField0,1,0,1,0 Global HostButt:TGadget=CreateButton("Host",9,375,67,15,EditWindow,1) SetGadgetLayout HostButt,1,0,1,0 Global btnButton1:TGadget=CreateButton("Connect",13,435,64,15,EditWindow,1) SetGadgetLayout btnButton1,1,0,1,0 Global IPtxt:TGadget=CreateTextField(87,433,96,20,EditWindow) SetGadgetLayout IPtxt,1,0,1,0 Global NameTXT:TGadget=CreateTextField(423,408,96,20,EditWindow) SetGadgetLayout NameTXT,1,0,1,0 Global lblLabel0=CreateLabel("Name",382,409,32,16,EditWindow,0) SetGadgetLayout lblLabel0,1,0,1,0 '-mainloop-------------------------------------------------------------- Repeat Select WaitEvent() Case EVENT_GADGETACTION ' interacted with gadget DoGadgetAction(EventSource()) Case EVENT_WINDOWCLOSE ' close gadget Exit End Select Forever '-gadget actions-------------------------------------------------------- Function DoGadgetAction( gadget:Object ) Select gadget Case tfdTextField0 If EventData () = 13 SetGadgetText teaTextArea0,GadgetText(tfdTextField0) DebugLog "Enter Hit" EndIf Case HostButt ' user pressed button Case btnButton1 ' user pressed button Case IPtxt If EventData() = 13 Then ' user pressed return in textfield EndIf Case NameTXT If EventData() = 13 Then ' user pressed return in textfield EndIf End Select End Function |
| ||
You can't test on return in a textfield as this is code is filtered out. One possible way is to have an OK_Button which can be pressed or will be invoked when hitting the return key. How does it work: Change one button to be an ok button e.g. Global HostButt:TGadget=CreateButton("Host",9,375,67,15,EditWindow,4) And what to do when return is pressed: Case HostButt ' user pressed button SetGadgetText teaTextArea0,GadgetText(tfdTextField0) If you put those 3 lines in your code, your input will be transfered to the textarea. jsp |
| ||
quick and dirty, add this right below your globals SetHotKeyEvent(KEY_RETURN,Null,CreateEvent(EVENT_GADGETACTION,tfdTextField0,KEY_RETURN)) this takes over all returns though... you will have to play around to get it to work with other gadgets that use return |
| ||
You could use SetGadgetHotKey; it sets the HotKey only for one gadget. |
| ||
not the same thing. setgadgethotkey set the hotkey which fires the default event. the problem here is there is no KEY_RETURN event for these gadgets. that's what sethotkeyevent does, is create an event whenever return is pressed. |
| ||
what sethotkeyevent does, is create an event whenever return is pressed that's what setgadgethotkey does, too (if you look at the maxgui source you'll see that in fact setgadgethotkey calls sethotkeyevent) |
| ||
I know what setgadgethotkey does... which is not the same thing as the line I posted. all setgadgethotkey does is create a generic EVENT_GADGETACTION. ev=CreateEvent( EVENT_GADGETACTION,Self ) hotkey=SetHotKeyEvent(key,modifier,ev,findowner()) As you can see, it doesn’t send KEY_RETURN like the line I posted. In addition your assertion that “in fact setgadgethotkey calls sethotkeyevent” is not really correct since that is only done in the windows version. |