Usablity:
authorTon Roosendaal <ton@blender.org>
Fri, 7 Jun 2013 15:42:26 +0000 (15:42 +0000)
committerTon Roosendaal <ton@blender.org>
Fri, 7 Jun 2013 15:42:26 +0000 (15:42 +0000)
Textbuttons: double click now selects entire words (like on file path segements)
Triple click was requested too, but that's not a WM event type yet.

source/blender/editors/interface/interface_handlers.c
source/blender/windowmanager/intern/wm_event_system.c

index 5ca22a3419e61a22830b9ff2359677b9e8fc5cf7..0d8c11c003638f0db21fdf98cb332f5bf8b8cab3 100644 (file)
@@ -2192,11 +2192,14 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
                        break;
                case LEFTMOUSE:
                {
+                       bool had_selection = but->selsta != but->selend;
+                       
                        /* exit on LMB only on RELEASE for searchbox, to mimic other popups, and allow multiple menu levels */
                        if (data->searchbox)
                                inbox = ui_searchbox_inside(data->searchbox, event->x, event->y);
 
-                       if (event->val == KM_PRESS) {
+                       /* for double click: we do a press again for when you first click on button (selects all text, no cursor pos) */
+                       if (event->val == KM_PRESS || event->val == KM_DBL_CLICK) {
                                mx = event->x;
                                my = event->y;
                                ui_window_to_block(data->region, block, &mx, &my);
@@ -2217,6 +2220,14 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
                                        retval = WM_UI_HANDLER_BREAK;
                                }
                        }
+                       
+                       /* only select a word in button if there was no selection before */
+                       if (event->val == KM_DBL_CLICK && had_selection == false) {
+                               ui_textedit_move(but, data, STRCUR_DIR_PREV, 0, STRCUR_JUMP_DELIM);
+                               ui_textedit_move(but, data, STRCUR_DIR_NEXT, true, STRCUR_JUMP_DELIM);
+                               retval = WM_UI_HANDLER_BREAK;
+                               changed = true;
+                       }
                        else if (inbox) {
                                button_activate_state(C, but, BUTTON_STATE_EXIT);
                                retval = WM_UI_HANDLER_BREAK;
index de961afefd829872f02303a4c9fa48f4013ace7d..ac714b09bb06b6a49c76c77945434c0ab83818e9 100644 (file)
@@ -380,8 +380,8 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, wmEvent *eve
        int retval;
        
        /* UI code doesn't handle return values - it just always returns break. 
-        * to make the DBL_CLICK conversion work, we just don't send this to UI */
-       if (event->val == KM_DBL_CLICK)
+        * to make the DBL_CLICK conversion work, we just don't send this to UI, except mouse clicks */
+       if (event->type != LEFTMOUSE && event->val == KM_DBL_CLICK)
                return WM_HANDLER_CONTINUE;
        
        /* UI is quite aggressive with swallowing events, like scrollwheel */