Hi Mike,
ComboBoxText's signal, onChanged, responds to both key events and mouse selection events, but I'd like write a callback that responds only to the mouse.
What I have so far [see reportSelected() below] uses writeln(getActiveText()) to illustrate harnessing this signal and it works as I'd like when mouse-selecting from the list. But typing into the Entry results in:
M
Mo
Mon
Mond... etc.
being echoed to the terminal and it looks messy, so I'm thinking there must be a way to filter out key presses so that no matter what user action triggers the signal, I can weed out the events I don't want to respond to. But to do that, I need access to the Event and I can't figure out how to do that from within a callback that isn't passed an Event object. After a few hours of searching and experimenting, I'm out of ideas. Can you advise, please?
Here's the class I'm working on:
class DayComboBoxText : ComboBoxText
{
string[] days = ["yesterday", "today", "tomorrow"];
bool entryOn = true;
this()
{
super(entryOn);
foreach(day; days)
{
appendText(day);
}
addOnKeyRelease(&echoToTerminal);
addOnChanged(&reportSelected);
} // this()
bool echoToTerminal(Event event, Widget w)
{
bool stopHereFlag = true;
if(event.type == EventType.KEY_RELEASE)
{
GdkEventKey* keyEvent = event.key;
if(keyEvent.keyval == GdkKeysyms.GDK_Return)
{
writeln(getActiveText());
}
}
return(stopHereFlag);
} // echoToTerminal()
void reportSelected(ComboBoxText cbt)
{
writeln(getActiveText());
} // reportSelected()
} // class DayComboBoxText