I am attempting to listen for key press events on the TGComboBox component; however, the HandleKey(Event_t *) is never invoked. I believe in this case, the function is inherited from TGFrame.
I’ve been trying to see if listening for key press events on the other components within the TGComboBox would work – such as the TGTextEntry or TGListBox. However, so far I have not had any success.
Is there a way to receive key press events in a TGComboBox? If so, how would I go about doing so?
Thanks!
Hi,
This could be a solution (actually probably the only one):
...
fCombo = new TGComboBox(fF2, "", 88);
fF2->AddFrame(fCombo, fL3);
fCombo->GetTextEntry()->Connect("ProcessedEvent(Event_t*)", 0, 0,
"ProcessedEvent(Event_t*)");
...
Checking with this slot:
void ProcessedEvent(Event_t *ev)
{
if (ev->fType != kGKeyPress) return;
printf("ProcessedEvent() : ev->fType = %d, Key pressed = %c\n",
ev->fType, ev->fCode);
}
Gives, when pressing keys in the combobox text entry:
ProcessedEvent() : ev->fType = 0, Key pressed = ,
ProcessedEvent() : ev->fType = 0, Key pressed = ,
ProcessedEvent() : ev->fType = 0, Key pressed = ,
ProcessedEvent() : ev->fType = 0, Key pressed = ,
ProcessedEvent() : ev->fType = 0, Key pressed = l
ProcessedEvent() : ev->fType = 0, Key pressed = k
ProcessedEvent() : ev->fType = 0, Key pressed = j
ProcessedEvent() : ev->fType = 0, Key pressed = l
ProcessedEvent() : ev->fType = 0, Key pressed = k
ProcessedEvent() : ev->fType = 0, Key pressed = j
ProcessedEvent() : ev->fType = 0, Key pressed = l
ProcessedEvent() : ev->fType = 0, Key pressed = k
ProcessedEvent() : ev->fType = 0, Key pressed = j
ProcessedEvent() : ev->fType = 0, Key pressed = l
Cheers, Bertrand.