ComboBoxGadget + #PB_ComboBox_Editable

Post bugreports for the Windows version here
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

ComboBoxGadget + #PB_ComboBox_Editable

Post by Lunasole »

If I don't mind this problem already was in some previous versions, and seems still remains (unlike versions without C backend, again if I'm not wrong).

Here if just typing any text all goes OK, but if trying to select predefined item, it returns empty text when getting text at event.
(while without #PB_ComboBox_Editable flag all goes OK).

Code: Select all

EnableExplicit

Global W = OpenWindow(#PB_Any, 100, 100, 200, 200, "test")
Global A = ComboBoxGadget(#PB_Any, 0,0, 100, 30, #PB_ComboBox_Editable)
AddGadgetItem(A, -1, "1")
AddGadgetItem(A, -1, "2")

Procedure EditCB()
	Debug "Text: " + GetGadgetText(A)
EndProcedure

BindEvent(#PB_Event_Gadget, @EditCB(), W)

Repeat
	If WaitWindowEvent(1) = #PB_Event_CloseWindow
		Break
	EndIf
ForEver
Last edited by Lunasole on Fri Mar 31, 2023 5:49 pm, edited 1 time in total.
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: ComboBoxGadget + #PB_ComboBox_Editable

Post by Lunasole »

Also checking further, it works OK without BindEvent.
The problem is when using BindEvent/BindGadgetEvent.

Code: Select all

EnableExplicit

Global W = OpenWindow(#PB_Any, 100, 100, 200, 200, "test")
Global A = ComboBoxGadget(#PB_Any, 0,0, 100, 30, #PB_ComboBox_Editable)
AddGadgetItem(A, -1, "1")
AddGadgetItem(A, -1, "2")

Repeat
	Define E = WaitWindowEvent(1)
	
	If E = #PB_Event_Gadget
		If EventType() = #PB_EventType_Change
			Debug "Text: " + GetGadgetText(A)
		EndIf
	ElseIf E = #PB_Event_CloseWindow
		Break
	EndIf
ForEver
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: ComboBoxGadget + #PB_ComboBox_Editable

Post by Lunasole »

Maybe I even posted about that year or more ago, can't remember such details (or maybe I thought to post and didn't posted). I just remember once I also encountered this problem in that my DialogDesigner2.
Anyway a brief search didn't showed about this.
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
User avatar
BI2
User
User
Posts: 10
Joined: Sun Jul 22, 2007 6:56 pm
Location: Germany

Re: ComboBoxGadget + #PB_ComboBox_Editable

Post by BI2 »

Have the same Problem in my Project.

No Problem with PB Versions 5.xx

No Problem with PB Version 6.00

The Problem is since PB Version 6.01
User avatar
HeX0R
Addict
Addict
Posts: 980
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: ComboBoxGadget + #PB_ComboBox_Editable

Post by HeX0R »

BI2 wrote: Fri Jun 30, 2023 6:49 pm Have the same Problem in my Project.

No Problem with PB Versions 5.xx

No Problem with PB Version 6.00

The Problem is since PB Version 6.01
I can confirm that!
In fact GetGadgetState() returns -1, whereas all versions <= PB6.00 work fine (output 0, when you've selected the first entry).
Here is another example, just in case this is somehow different to the GetGadgetText() example from Lunasole.

Code: Select all

Procedure.s GetXMLString()
	Protected XML$

	XML$ + "<?xml version='1.0' encoding='UTF-16'?>"
	XML$ + ""
	XML$ + "<dialogs><!--Created by Dialog Design0R V1.84 => get it from: https://hex0rs.coderbu.de/en/sdm_downloads/dialogdesign0r/-->"
	XML$ + "  <window flags='#PB_Window_SystemMenu | #PB_Window_ScreenCentered' text='bla' name='window_1' xpos='0' ypos='0'>"
	XML$ + "    <vbox>"
	XML$ + "      <combobox flags='#PB_ComboBox_Editable' width='200' name='combobox_1' onchange='OnChangeCombo()'/> "
	XML$ + "    </vbox>"
	XML$ + "  </window>"
	XML$ + "</dialogs><!--DDesign0R Definition: PureBasic|1|1|1|_|-|0|AddOn:3:0-->"

	ProcedureReturn XML$
EndProcedure
;Test it
Runtime Procedure OnChangeCombo()
	Debug "Selected Entry: " + Str(GetGadgetState(DialogGadget(0, "combobox_1")))
EndProcedure




a$ = GetXMLString()
If ParseXML(0, a$) And XMLStatus(0) = #PB_XML_Success
	CreateDialog(0)
	If OpenXMLDialog(0, 0, "window_1")
		AddGadgetItem(DialogGadget(0, "combobox_1"), -1, "select me")
		AddGadgetItem(DialogGadget(0, "combobox_1"), -1, "nop")
		AddGadgetItem(DialogGadget(0, "combobox_1"), -1, "nop")
		AddGadgetItem(DialogGadget(0, "combobox_1"), -1, "nop")
		While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend
	EndIf
EndIf
Post Reply