Skip to content

Commit 4e9987d

Browse files
committed
ComboGroup now properly reacts on the 'ESC' key pressure and hides the dropdown list.
1 parent ec3c785 commit 4e9987d

3 files changed

Lines changed: 35 additions & 5 deletions

File tree

CHANGELOG

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Added process_pending_events() in the tk::Display class for handling pending
1212
events at the main loop start and at the main loop end.
1313
* Changed behaviour of the AudioSample widget related to displaying load status.
14-
* ComboBox now properly reacts on the 'ESC' key pressure and hides the dropdown list.
14+
* ComboBox and ComboGroup now properly react on the 'ESC' key pressure and hides the dropdown list.
1515
* Updated build scripts.
1616

1717
=== 1.0.33 ===

include/lsp-plug.in/tk/widgets/compound/ComboGroup.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,15 @@ namespace lsp
150150
ListBoxItem *current_item();
151151
bool scroll_item(ssize_t direction, size_t count);
152152

153+
protected:
153154
static void on_add_widget(void *obj, Property *prop, void *w);
154155
static void on_remove_widget(void *obj, Property *prop, void *w);
156+
157+
protected:
155158
static status_t slot_on_change(Widget *sender, void *ptr, void *data);
156159
static status_t slot_on_submit(Widget *sender, void *ptr, void *data);
160+
static status_t slot_on_cancel(Widget *sender, void *ptr, void *data);
161+
static status_t slot_on_listbox_cancel(Widget *sender, void *ptr, void *data);
157162

158163
protected:
159164
virtual Widget *find_widget(ssize_t x, ssize_t y) override;
@@ -218,6 +223,7 @@ namespace lsp
218223

219224
virtual status_t on_change();
220225
virtual status_t on_submit();
226+
virtual status_t on_cancel();
221227

222228
};
223229

src/main/widgets/compound/ComboGroup.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ namespace lsp
234234
handler_id_t id;
235235
id = sSlots.add(SLOT_CHANGE, slot_on_change, self());
236236
if (id >= 0) id = sSlots.add(SLOT_SUBMIT, slot_on_change, self());
237+
if (id >= 0) id = sSlots.add(SLOT_CANCEL, slot_on_cancel, self());
238+
if (id < 0)
239+
return -id;
240+
241+
// Bind ListBox slots
242+
id = sLBox.slots()->bind(SLOT_CANCEL, slot_on_listbox_cancel, self());
237243
if (id < 0)
238244
return -id;
239245

@@ -669,14 +675,27 @@ namespace lsp
669675

670676
status_t ComboGroup::slot_on_change(Widget *sender, void *ptr, void *data)
671677
{
672-
ComboGroup *_this = widget_ptrcast<ComboGroup>(ptr);
673-
return (_this != NULL) ? _this->on_change() : STATUS_BAD_ARGUMENTS;
678+
ComboGroup *const self = widget_ptrcast<ComboGroup>(ptr);
679+
return (self != NULL) ? self->on_change() : STATUS_BAD_ARGUMENTS;
674680
}
675681

676682
status_t ComboGroup::slot_on_submit(Widget *sender, void *ptr, void *data)
677683
{
678-
ComboGroup *_this = widget_ptrcast<ComboGroup>(ptr);
679-
return (_this != NULL) ? _this->on_submit() : STATUS_BAD_ARGUMENTS;
684+
ComboGroup *const self = widget_ptrcast<ComboGroup>(ptr);
685+
return (self != NULL) ? self->on_submit() : STATUS_BAD_ARGUMENTS;
686+
}
687+
688+
status_t ComboGroup::slot_on_cancel(Widget *sender, void *ptr, void *data)
689+
{
690+
ComboGroup *const self = widget_ptrcast<ComboGroup>(ptr);
691+
return (self != NULL) ? self->on_cancel() : STATUS_BAD_ARGUMENTS;
692+
}
693+
694+
status_t ComboGroup::slot_on_listbox_cancel(Widget *sender, void *ptr, void *data)
695+
{
696+
ComboGroup * const self = widget_ptrcast<ComboGroup>(ptr);
697+
self->sOpened.set(false);
698+
return self->sSlots.execute(SLOT_CANCEL, self, NULL);
680699
}
681700

682701
status_t ComboGroup::on_change()
@@ -689,6 +708,11 @@ namespace lsp
689708
return STATUS_OK;
690709
}
691710

711+
status_t ComboGroup::on_cancel()
712+
{
713+
return STATUS_OK;
714+
}
715+
692716
status_t ComboGroup::on_mouse_down(const ws::event_t *e)
693717
{
694718
if (nMBState == 0)

0 commit comments

Comments
 (0)