summaryrefslogtreecommitdiff
path: root/src/ui/inputwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-12 22:27:02 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-12 22:27:02 +0200
commit9cdf86dc8dda0ebf777dfdec5c1eeef53371a1ee (patch)
tree340b4bac4c96c9711e4845ff994701176a3dd267 /src/ui/inputwidget.c
parent3e56e0f1ca20d7d0489036ce0f0bca97d596f0d5 (diff)
Cut/copy/paste paste via menus
IssueID #175
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r--src/ui/inputwidget.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index eac195b9..f4302887 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -314,9 +314,13 @@ void selectAll_InputWidget(iInputWidget *d) {
314 refresh_Widget(as_Widget(d)); 314 refresh_Widget(as_Widget(d));
315} 315}
316 316
317iLocalDef iBool isEditing_InputWidget_(const iInputWidget *d) {
318 return (flags_Widget(constAs_Widget(d)) & selected_WidgetFlag) != 0;
319}
320
317void begin_InputWidget(iInputWidget *d) { 321void begin_InputWidget(iInputWidget *d) {
318 iWidget *w = as_Widget(d); 322 iWidget *w = as_Widget(d);
319 if (flags_Widget(w) & selected_WidgetFlag) { 323 if (isEditing_InputWidget_(d)) {
320 /* Already active. */ 324 /* Already active. */
321 return; 325 return;
322 } 326 }
@@ -346,7 +350,7 @@ void begin_InputWidget(iInputWidget *d) {
346 350
347void end_InputWidget(iInputWidget *d, iBool accept) { 351void end_InputWidget(iInputWidget *d, iBool accept) {
348 iWidget *w = as_Widget(d); 352 iWidget *w = as_Widget(d);
349 if (~flags_Widget(w) & selected_WidgetFlag) { 353 if (!isEditing_InputWidget_(d)) {
350 /* Was not active. */ 354 /* Was not active. */
351 return; 355 return;
352 } 356 }
@@ -614,6 +618,15 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
614 end_InputWidget(d, iTrue); 618 end_InputWidget(d, iTrue);
615 return iFalse; 619 return iFalse;
616 } 620 }
621 else if ((isCommand_UserEvent(ev, "copy") || isCommand_UserEvent(ev, "input.copy")) &&
622 isEditing_InputWidget_(d)) {
623 copy_InputWidget_(d, argLabel_Command(command_UserEvent(ev), "cut"));
624 return iTrue;
625 }
626 else if (isCommand_UserEvent(ev, "input.paste") && isEditing_InputWidget_(d)) {
627 paste_InputWidget_(d);
628 return iTrue;
629 }
617 else if (isCommand_UserEvent(ev, "theme.changed")) { 630 else if (isCommand_UserEvent(ev, "theme.changed")) {
618 if (d->buffered) { 631 if (d->buffered) {
619 updateBuffered_InputWidget_(d); 632 updateBuffered_InputWidget_(d);
@@ -675,6 +688,17 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
675 case finished_ClickResult: 688 case finished_ClickResult:
676 return iTrue; 689 return iTrue;
677 } 690 }
691 if (ev->type == SDL_MOUSEBUTTONDOWN && ev->button.button == SDL_BUTTON_RIGHT &&
692 contains_Widget(w, init_I2(ev->button.x, ev->button.y))) {
693 iWidget *clipMenu = findWidget_App("clipmenu");
694 if (isVisible_Widget(clipMenu)) {
695 closeMenu_Widget(clipMenu);
696 }
697 else {
698 openMenuFlags_Widget(clipMenu, mouseCoord_Window(get_Window()), iFalse);
699 }
700 return iTrue;
701 }
678 if (ev->type == SDL_KEYUP && isFocused_Widget(w)) { 702 if (ev->type == SDL_KEYUP && isFocused_Widget(w)) {
679 return iTrue; 703 return iTrue;
680 } 704 }