How to set the role of a ComboBoxGadget to be a proper combo box?

Just starting out? Need help? Post your questions and find answers here.
Quin
Posts: 118
Joined: Wed Nov 08, 2023 4:38 pm

How to set the role of a ComboBoxGadget to be a proper combo box?

Post by Quin »

I'm trying to make an app with two noneditable combo boxes. This code almost entirely works, but my screen reader thinks the combo boxes are text fields, not combo boxes. I can't type in them, but there is a role for this, called combobox. I just can't get it to apply. What am I doing wrong? It says private variables are not valid in this context.

Code: Select all

EnableExplicit

#AppName$ = "Test"
Enumeration Windows
#Window_Main
EndEnumeration

Enumeration Gadgets
#Gadget_FirstLabel
#Gadget_FirstCombo
#Gadget_SecondLabel
#Gadget_SecondCombo
EndEnumeration

Macro MakeComboRole(_Elem)
! $(spider_gadgetid(_Elem)).attr("role", "combobox");
EndMacro

OpenWindow(#Window_Main, #PB_Ignore, #PB_Ignore, 640, 480, #AppName$)
TextGadget(#Gadget_FirstLabel, 5, 5, 30, 5, "Select first ")
ComboBoxGadget(#Gadget_FirstCombo, 5, 15, 250, 25)
TextGadget(#Gadget_SecondLabel, 300, 5, 30, 5, "Select second")
ComboBoxGadget(#Gadget_SecondCombo, 300, 15, 250, 25)
MakeComboRole(#Gadget_FirstCombo)
MakeComboRole(#Gadget_SecondCombo)
AddGadgetItem(#Gadget_FirstCombo, -1, "Test")
SetGadgetState(#Gadget_FirstCombo, 0)