diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-06 22:45:15 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-06 22:45:15 +0300 |
commit | a364d9456dfdfd8181904fca6308e9c36eefd10a (patch) | |
tree | f355ded227cf52053784b991f5d8441a5502e447 /src/ui/window.c | |
parent | 52a1652536e4e27751ac121009f85113e72afe7d (diff) |
LookupWidget: Keyboard focus and cursor
Diffstat (limited to 'src/ui/window.c')
-rw-r--r-- | src/ui/window.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/ui/window.c b/src/ui/window.c index 78567bb5..b886a686 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -203,9 +203,17 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { | |||
203 | refresh_Widget(navBar); | 203 | refresh_Widget(navBar); |
204 | return iFalse; | 204 | return iFalse; |
205 | } | 205 | } |
206 | else if (equal_Command(cmd, "input.edited")) { | ||
207 | iAnyObject *url = findChild_Widget(navBar, "url"); | ||
208 | if (pointer_Command(cmd) == url) { | ||
209 | submit_LookupWidget(findWidget_App("lookup"), text_InputWidget(url)); | ||
210 | return iTrue; | ||
211 | } | ||
212 | } | ||
206 | else if (equal_Command(cmd, "input.ended")) { | 213 | else if (equal_Command(cmd, "input.ended")) { |
207 | iInputWidget *url = findChild_Widget(navBar, "url"); | 214 | iInputWidget *url = findChild_Widget(navBar, "url"); |
208 | if (arg_Command(cmd) && pointer_Command(cmd) == url) { | 215 | if (arg_Command(cmd) && pointer_Command(cmd) == url && |
216 | !isFocused_Widget(findWidget_App("lookup"))) { | ||
209 | postCommandf_App( | 217 | postCommandf_App( |
210 | "open url:%s", | 218 | "open url:%s", |
211 | cstr_String(absoluteUrl_String(&iStringLiteral(""), text_InputWidget(url)))); | 219 | cstr_String(absoluteUrl_String(&iStringLiteral(""), text_InputWidget(url)))); |
@@ -276,8 +284,7 @@ static iBool handleSearchBarCommands_(iWidget *searchBar, const char *cmd) { | |||
276 | if (equal_Command(cmd, "input.ended") && | 284 | if (equal_Command(cmd, "input.ended") && |
277 | cmp_String(string_Command(cmd, "id"), "find.input") == 0) { | 285 | cmp_String(string_Command(cmd, "id"), "find.input") == 0) { |
278 | iInputWidget *input = findChild_Widget(searchBar, "find.input"); | 286 | iInputWidget *input = findChild_Widget(searchBar, "find.input"); |
279 | if (arg_Command(cmd) && argLabel_Command(cmd, "enter") && | 287 | if (arg_Command(cmd) && argLabel_Command(cmd, "enter") && isVisible_Widget(input)) { |
280 | isVisible_Widget(as_Widget(input))) { | ||
281 | postCommand_App("find.next"); | 288 | postCommand_App("find.next"); |
282 | /* Keep focus when pressing Enter. */ | 289 | /* Keep focus when pressing Enter. */ |
283 | if (!isEmpty_String(text_InputWidget(input))) { | 290 | if (!isEmpty_String(text_InputWidget(input))) { |
@@ -349,6 +356,7 @@ static void setupUserInterface_Window(iWindow *d) { | |||
349 | iInputWidget *url = new_InputWidget(0); | 356 | iInputWidget *url = new_InputWidget(0); |
350 | setSelectAllOnFocus_InputWidget(url, iTrue); | 357 | setSelectAllOnFocus_InputWidget(url, iTrue); |
351 | setId_Widget(as_Widget(url), "url"); | 358 | setId_Widget(as_Widget(url), "url"); |
359 | setNotifyEdits_InputWidget(url, iTrue); | ||
352 | setTextCStr_InputWidget(url, "gemini://"); | 360 | setTextCStr_InputWidget(url, "gemini://"); |
353 | addChildFlags_Widget(navBar, iClob(url), expand_WidgetFlag); | 361 | addChildFlags_Widget(navBar, iClob(url), expand_WidgetFlag); |
354 | setId_Widget(addChild_Widget( | 362 | setId_Widget(addChild_Widget( |
@@ -406,7 +414,7 @@ static void setupUserInterface_Window(iWindow *d) { | |||
406 | addChild_Widget(searchBar, iClob(newIcon_LabelWidget("\u2a2f", SDLK_ESCAPE, 0, "find.close"))); | 414 | addChild_Widget(searchBar, iClob(newIcon_LabelWidget("\u2a2f", SDLK_ESCAPE, 0, "find.close"))); |
407 | } | 415 | } |
408 | iLookupWidget *lookup = new_LookupWidget(); | 416 | iLookupWidget *lookup = new_LookupWidget(); |
409 | addChildFlags_Widget(d->root, iClob(lookup), hidden_WidgetFlag); | 417 | addChildFlags_Widget(d->root, iClob(lookup), fixedPosition_WidgetFlag | hidden_WidgetFlag); |
410 | iWidget *tabsMenu = makeMenu_Widget(d->root, | 418 | iWidget *tabsMenu = makeMenu_Widget(d->root, |
411 | (iMenuItem[]){ | 419 | (iMenuItem[]){ |
412 | { "Close Tab", 0, 0, "tabs.close" }, | 420 | { "Close Tab", 0, 0, "tabs.close" }, |