Open a ComboBoxGadget - List by clicking on the text

Got an idea for enhancing SpiderBasic? New command(s) you'd like to see?
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Open a ComboBoxGadget - List by clicking on the text

Post by Peter »

Hello,

a non-editable ComboBoxGadget should open its items when clicking on the Text (like in PureBasic):

Example:

Code: Select all

If OpenWindow(0, 0, 0, 270, 85, "ComboBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	
	ComboBoxGadget(0, 10, 10, 250, 25, #PB_ComboBox_Editable)
	AddGadgetItem(0, -1, "ComboBox editable...")
	
	ComboBoxGadget(1, 10, 50, 250, 25)
	For Index = 0 To 5
		AddGadgetItem(1, -1, "ComboBox item " + Index)
	Next
	
	SetGadgetState(0, 0)
	SetGadgetState(1, 2)    ; set (beginning with 0) the third item as active one
	
	CompilerIf #PB_Compiler_OS <> #PB_OS_Web
		Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
	CompilerEndIf

EndIf
Image
Image

@all: is there a quick workaround for this?

Thanks in advance & Greetings ... Peter
User avatar
SparrowhawkMMU
Posts: 281
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Re: Open a ComboBoxGadget - List by clicking on the text

Post by SparrowhawkMMU »

+1

That would be very nice. Good suggestion!
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Open a ComboBoxGadget - List by clicking on the text

Post by Peter »

got it. Not perfect, but better than nothing...

Code: Select all

Enumeration
	#myWindow
	#myComboBox
EndEnumeration

Procedure ComboBoxGadgetFocusEvent()
	Protected GID = GadgetID(#myComboBox)
	! dijit.byId(v_gid.gadget.id).toggleDropDown();
EndProcedure


If OpenWindow(#myWindow, 0, 0, 270, 85, "ComboBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	
	ComboBoxGadget(#myComboBox, 10, 50, 250, 25)
	
	For Index = 0 To 5
		AddGadgetItem(#myComboBox, -1, "ComboBox item " + Index)
	Next
	
	SetGadgetState(#myComboBox, 2)    ; set (beginning with 0) the third item as active one
	
	CompilerIf #PB_Compiler_OS = #PB_OS_Web
		BindGadgetEvent(#myComboBox, @ComboBoxGadgetFocusEvent(), #PB_EventType_Focus)
	CompilerEndIf
	
	CompilerIf #PB_Compiler_OS <> #PB_OS_Web
		Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
	CompilerEndIf
	
EndIf
(nevertheless a native solution would be better ;-) )

Greetings ... Peter
Post Reply