summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-11-16 16:01:38 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-11-16 16:03:25 +0200
commitfa65ced22f1c74a095394a0e3362b9939321c800 (patch)
treecac07c2aa5274e3c1fc763416a541b4ad9a3ef25 /src/ui
parent74861693e2e51b2ba4da7dd6c36f9e8c3d9b76e9 (diff)
Closing the sidebar with Escape
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/sidebarwidget.c12
-rw-r--r--src/ui/window.c12
2 files changed, 17 insertions, 7 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 88ffffba..f17f82a1 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -771,6 +771,18 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
771 } 771 }
772 } 772 }
773 } 773 }
774 if (ev->type == SDL_KEYDOWN) {
775 const int key = ev->key.keysym.sym;
776 const int kmods = keyMods_Sym(ev->key.keysym.mod);
777 /* Hide the sidebar when Escape is pressed. */
778 if (kmods == 0 && key == SDLK_ESCAPE && isVisible_Widget(d)) {
779 setFlags_Widget(w, hidden_WidgetFlag, iTrue);
780 arrange_Widget(w->parent);
781 updateSize_DocumentWidget(document_App());
782 refresh_Widget(w->parent);
783 return iTrue;
784 }
785 }
774 if (hoverItem_ListWidget(d->list) || isVisible_Widget(d->menu)) { 786 if (hoverItem_ListWidget(d->list) || isVisible_Widget(d->menu)) {
775 processContextMenuEvent_Widget(d->menu, ev, {}); 787 processContextMenuEvent_Widget(d->menu, ev, {});
776 } 788 }
diff --git a/src/ui/window.c b/src/ui/window.c
index ba6ee869..63f19e3f 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -326,7 +326,7 @@ static iBool handleSearchBarCommands_(iWidget *searchBar, const char *cmd) {
326 else if (equal_Command(cmd, "focus.gained")) { 326 else if (equal_Command(cmd, "focus.gained")) {
327 if (pointer_Command(cmd) == findChild_Widget(searchBar, "find.input")) { 327 if (pointer_Command(cmd) == findChild_Widget(searchBar, "find.input")) {
328 if (!isVisible_Widget(searchBar)) { 328 if (!isVisible_Widget(searchBar)) {
329 setFlags_Widget(searchBar, hidden_WidgetFlag, iFalse); 329 setFlags_Widget(searchBar, hidden_WidgetFlag | disabled_WidgetFlag, iFalse);
330 arrange_Widget(get_Window()->root); 330 arrange_Widget(get_Window()->root);
331 refresh_App(); 331 refresh_App();
332 } 332 }
@@ -334,16 +334,13 @@ static iBool handleSearchBarCommands_(iWidget *searchBar, const char *cmd) {
334 } 334 }
335 else if (equal_Command(cmd, "find.close")) { 335 else if (equal_Command(cmd, "find.close")) {
336 if (isVisible_Widget(searchBar)) { 336 if (isVisible_Widget(searchBar)) {
337 setFlags_Widget(searchBar, hidden_WidgetFlag, iTrue); 337 setFlags_Widget(searchBar, hidden_WidgetFlag | disabled_WidgetFlag, iTrue);
338 arrange_Widget(searchBar->parent); 338 arrange_Widget(searchBar->parent);
339 if (isFocused_Widget(findChild_Widget(searchBar, "find.input"))) { 339 if (isFocused_Widget(findChild_Widget(searchBar, "find.input"))) {
340 setFocus_Widget(NULL); 340 setFocus_Widget(NULL);
341 } 341 }
342 refresh_Widget(searchBar->parent); 342 refresh_Widget(searchBar->parent);
343 } 343 }
344 else if (isVisible_Widget(findWidget_App("sidebar"))) {
345 postCommand_App("sidebar.toggle");
346 }
347 return iTrue; 344 return iTrue;
348 } 345 }
349 return iFalse; 346 return iFalse;
@@ -446,8 +443,9 @@ static void setupUserInterface_Window(iWindow *d) {
446 iWidget *searchBar = new_Widget(); 443 iWidget *searchBar = new_Widget();
447 setId_Widget(searchBar, "search"); 444 setId_Widget(searchBar, "search");
448 setFlags_Widget(searchBar, 445 setFlags_Widget(searchBar,
449 hidden_WidgetFlag | collapse_WidgetFlag | arrangeHeight_WidgetFlag | 446 hidden_WidgetFlag | disabled_WidgetFlag | collapse_WidgetFlag |
450 resizeChildren_WidgetFlag | arrangeHorizontal_WidgetFlag, 447 arrangeHeight_WidgetFlag | resizeChildren_WidgetFlag |
448 arrangeHorizontal_WidgetFlag,
451 iTrue); 449 iTrue);
452 addChild_Widget(div, iClob(searchBar)); 450 addChild_Widget(div, iClob(searchBar));
453 setBackgroundColor_Widget(searchBar, uiBackground_ColorId); 451 setBackgroundColor_Widget(searchBar, uiBackground_ColorId);