You are welcome
I agree with you about adding it to feature request
It will cost Fred nothing
Editable Combogadget problem
Re: Editable Combogadget problem
Egypt my love
Re: Editable Combogadget problem
My typical use with ComboBoxGadget()'s:
Code: Select all
EnableExplicit
Global.i win0,cmb1,btn,btn2,i,evWW,evT
Global.s cmb1$
Global NewList llCMB.s()
Procedure.i gad_cmb_fill(gN.i, List llG.s(), Latest$)
Protected.i nPts, nth
Protected.s r$
ClearGadgetItems(gN)
SortList(llG(), #PB_Sort_Ascending) ; Use qsort() for Natural string sorting. (1,2,10 instead of 1,10,2.)
ForEach llG()
If llG() <> r$
r$ = llG()
AddGadgetItem(gN, -1, r$)
If r$ = Latest$
SetGadgetState(gN, nPts)
EndIf
nPts + 1
EndIf
Next
ProcedureReturn nPts
EndProcedure
win0 = OpenWindow(#PB_Any, 0, 0, 600, 400, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
cmb1 = ComboBoxGadget(#PB_Any, 10, 10, 200, 30, #PB_ComboBox_Editable)
btn = ButtonGadget(#PB_Any, 10, 200, 200, 30, "Get ComboBox selection")
btn2 = ButtonGadget(#PB_Any, 10, 240, 200, 30, "")
For i = 1 To 10
cmb1$ = "Item " + Str(i)
AddGadgetItem(cmb1, -1, cmb1$)
AddElement(llCMB())
llCMB() = cmb1$
Next i
SetGadgetState(cmb1, i-2) ; Last item added = current gadget item text.
SetGadgetText(btn2, cmb1$)
Repeat
evWW = WaitWindowEvent()
Select evWW
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
evT = EventType()
Select EventGadget()
Case cmb1
If evT = #PB_EventType_Change
cmb1$ = GetGadgetText(cmb1)
ElseIf evT = #PB_EventType_LostFocus
AddElement(llCMB())
llCMB() = cmb1$
gad_cmb_fill(cmb1, llCMB(), cmb1$)
EndIf
Case btn
SetGadgetText(btn2, cmb1$)
EndSelect
EndSelect
ForEver
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
- robertfern
- User
- Posts: 23
- Joined: Fri Feb 02, 2018 10:33 pm
- Location: New Jersey
Re: Editable Combogadget problem
I have another issue with combo box on mac.
When you click on the down arrow on the ComboBox, the dropdown list only shows for a second. It should stay down. It will only stay down if you keep the mouse button down. This is not standard Mac Behavior. I haven't tested it on a PC.
Thanks,
Robert
-------
PB on Mac Sierra with PB 5.62
When you click on the down arrow on the ComboBox, the dropdown list only shows for a second. It should stay down. It will only stay down if you keep the mouse button down. This is not standard Mac Behavior. I haven't tested it on a PC.
Thanks,
Robert
-------
PB on Mac Sierra with PB 5.62
Mac OSX Ventura & Windows 10, PB 6.04
- Michael Vogel
- Addict
- Posts: 2680
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: Editable Combogadget problem
Starting from the first post, I would recommend to add the line "SetGadgetState(Combo_0,-1)"...
Code: Select all
Global Window_0
Global Combo_0,Button_0,Button_1
Window_0 = OpenWindow(#PB_Any, 0, 0, 600, 400, "", #PB_Window_SystemMenu)
Combo_0 = ComboBoxGadget(#PB_Any, 120, 40, 200, 30, #PB_ComboBox_Editable)
Button_0 = ButtonGadget(#PB_Any, 240, 140, 100, 20, "")
Button_1 = ButtonGadget(#PB_Any, 140, 140, 100, 20, "Set")
;Load Combo List
For iLoop = 1 To 10
AddGadgetItem(Combo_0,-1,"Item " + Str(iLoop))
Next
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
End
Case #PB_Event_Gadget
Select EventGadget()
Case Button_0
Debug GetGadgetText(Combo_0)
Case Button_1
SetGadgetState(Combo_0,-1)
SetGadgetText(Combo_0,"test text")
EndSelect
EndSelect
ForEver
-
- Addict
- Posts: 1309
- Joined: Fri Aug 28, 2015 6:10 pm
- Location: Portugal
Re: Editable Combogadget problem
Tried Setgadgetstate -1 and after setting the test text and clicking the right button nothing is returned?
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
- robertfern
- User
- Posts: 23
- Joined: Fri Feb 02, 2018 10:33 pm
- Location: New Jersey
Re: Editable Combogadget problem
I fixed the problem on Mac when you first click the "Set" button after you selected an item from the list,
it used to first go blank. You had to click it twice to set the text to "Test Text"
Now it works.
First you have to "deselectItemAtIndex" in cocoa
only after the index is now "-1", you can set the text
it used to first go blank. You had to click it twice to set the text to "Test Text"
Now it works.
First you have to "deselectItemAtIndex" in cocoa
only after the index is now "-1", you can set the text
Code: Select all
Global Window_0
Global Combo_0,Button_0,Button_1
Window_0 = OpenWindow(#PB_Any, 0, 0, 600, 400, "", #PB_Window_SystemMenu)
Combo_0 = ComboBoxGadget(#PB_Any, 120, 40, 200, 25, #PB_ComboBox_Editable)
Button_0 = ButtonGadget(#PB_Any, 240, 140, 100, 25, "Debug")
Button_1 = ButtonGadget(#PB_Any, 140, 140, 100, 25, "Set")
;Load Combo List
For iLoop = 1 To 10
AddGadgetItem(Combo_0,-1,"Item " + Str(iLoop))
Next
Define NumItems.i = 0, VisItems.i = 0, MyString.s
CocoaMessage(0, GadgetID(Combo_0), "setNumberOfVisibleItems:",VisItems)
Debug "Visible Items = " + VisItems
*Buffer = AllocateMemory(256)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case Combo_0
Buffer$ = GetGadgetText(Combo_0)
Debug "Gadget Text = " + GetGadgetText(Combo_0)
Case Button_0
Debug "Gadget Text = " + GetGadgetText(Combo_0)
Debug "Selected Item = " + CocoaMessage(0 ,GadgetID(Combo_0),"indexOfSelectedItem")
Case Button_1
Debug "Numitems = " +NumItems
Debug "Index = " + CocoaMessage(0 ,GadgetID(Combo_0),"indexOfSelectedItem")
; Have to remove the selection before you change the text
CocoaMessage(0,GadgetID(Combo_0),"deselectItemAtIndex:", CocoaMessage(0 ,GadgetID(Combo_0),"indexOfSelectedItem"))
SetGadgetText(Combo_0,"Test Text")
EndSelect
EndSelect
ForEver
FreeMemory(*Buffer)
Mac OSX Ventura & Windows 10, PB 6.04