Editable combobox's and the enter key
BlitzMax Forums/MaxGUI Module/Editable combobox's and the enter key
| ||
Is there a better way of doing this: http://www.blitzbasic.com/Community/posts.php?topic=58988 ?? |
| ||
Well, you don't need to code a custom ComboBoxText() function (if that helps) - you can just use GadgetText() for a cross-platform solution:Strict Local window:TGadget Local combobox:TGadget Local retbutt:TGadget window=CreateWindow("My Window",30,20,200,200) combobox=CreateComboBox(4,4,120,22,window,COMBOBOX_EDITABLE) AddGadgetItem combobox,"Short" AddGadgetItem combobox,"Medium" AddGadgetItem combobox,"Fat",True AddGadgetItem combobox,"Humungous" retbutt = CreateButton("Enter",125,4,40,20,window,BUTTON_OK) While WaitEvent() Select EventID() Case EVENT_GADGETACTION Print "eventdata="+EventData()+" "+EventText() Select EventSource() Case retbutt Print GadgetText(combobox) AddGadgetItem combobox,GadgetText(combobox) End Select Case EVENT_WINDOWCLOSE End End Select Wend |
| ||
Or is maybe the catch of the return key the problem? If you don't like the “Enter” button, just make it invisible (GadgetHide) or put the size to zero: retbutt = CreateButton("Enter",0,0,0,0,window,BUTTON_OK) |
| ||
Good suggestions, but... If you don't like the “Enter” button, just make it invisible (GadgetHide) or put the size to zero: Even though this may work on Windows, it may not work on the other platforms. Setting an unhidden button to maybe just 1 pixel tall/wide would perhaps be more advisable just in case. I'm sure there was a thread requesting SetGadgetFilter() for ComboBoxes - not sure why Skid chose not to implement this when he did textfields, but I'd prefer to find out if there was a reason before embarking on such a task. |
| ||
Actually i didn't try it on the other platforms and even 1 pixel can be a problem then (don't know), so GadgetHide should be the way to go i think. SetGadgetFilter would be probably a good solution as we could attach it to a single gadget, where the OK Button works more in general... What i don't like about the SetGadgetFilter is, that it uses the gadget context field, which is of enormous help and may the reason it was not chosen. Best would be if the context field is completely free and another one is only used internally. |
| ||
What i don't like about the SetGadgetFilter is, that it uses the gadget context field, which is of enormous help and may the reason it was not chosen. Best would be if the context field is completely free and another one is only used internally. Unfortunately, the context field in TGadget is there specifically for storing the parameter passed by SetGadgetFilter(). Perhaps you need a new GadgetExtra()/SetGadgetExtra() function pair? ;-) |
| ||
It's off topic now and i don't want to harvest this thread could you may put it in an extra one? Also to ask others what they think about it. Actually a GadgetExtra()/SetGadgetExtra() should have been there from the start (like for listitems), because now we have the problem with backward compatibility. My suggestion would be to take a new field for the SetGadgetFilter and a function pair as you suggested to set/get the context field. As skid approved that we can use it, probably a lot have it in use in their programs and changing only the filter for the TextField and the TextArea is much easier and would not hurt anybody. If you could implement it now with MaxGuiEx that would really be fine, because than there is an official way we can go. |
| ||
It's off topic now and i don't want to harvest this thread could you may put it in an extra one? Yes sir! |
| ||
This works without a button, but there is no possible way to tell if the return key was actually pressed:Strict Framework maxgui.drivers Import brl.eventqueue Local window:TGadget Local combobox:TGadget Local retbutt:TGadget window=CreateWindow("My Window",30,20,200,200) combobox=CreateComboBox(4,4,120,22,window,COMBOBOX_EDITABLE) AddGadgetItem combobox,"Short" AddGadgetItem combobox,"Medium" AddGadgetItem combobox,"Fat",True AddGadgetItem combobox,"Humungous" SetGadgetHotKey combobox, KEY_ENTER, Null 'retbutt = CreateButton("Enter",125,4,40,20,window,BUTTON_OK) While WaitEvent() Select EventID() Case EVENT_GADGETACTION 'Print "eventdata="+EventData()+" "+EventText() Print CurrentEvent.tostring() Select EventSource() Case combobox Print GadgetText(combobox) AddGadgetItem combobox,GadgetText(combobox) End Select Case EVENT_WINDOWCLOSE End End Select Wend If only we could attach an extra gadget to a hotkey.. |
| ||
Seb just managed to get the SetGadgetSensitivity() running also for ComboBoxes. If you then check the key events for every key pressed you could probably easily act on the return key. |
| ||
I don't see the thread on this, and it doesn't seem to be in svn (last I checked anyhow). |
| ||
It's at the end of the MaxGui Updates Discussion Thread: http://www.blitzbasic.com/Community/posts.php?topic=77664 I've managed to find a workaround for this, so now ComboBoxes behave as they should when SetGadgetSensitivity() is called on them in Windows. SVN probably not yet updated;), but i think it will come soon. |
| ||
SVN probably not yet updated;), but i think it will come soon. Had a few problems with the Cocoa module but most of those issues have been ironed out now... Also, I need to get the FLTK modules tested before I can send them to Mark and I no longer have a Linux partition on my PC. Sorry about the delay. Will update the worklog when it's committed. |