Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2013-11-25 20:40:08 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2013-11-25 20:42:07 +0400
commitd6e257d4474dbf8a055b10da1998c82b9c1e8f49 (patch)
tree65240b6fd15f66768a6abf1beea12b92d20a59b8 /source
parente626998a262ebe4f621b88eb09ece1a48c1a3ef8 (diff)
UIList: add proper support for ctrl-c/v (copy/paste) of names.
Dev notes: Another hack in ui_do_button(), to add a specific handling of LISTROW in case of copy/paste event, which fixes the same 'not working if no mouse mouve' issue for those actions as well. Also added an helper func to switch from listrow to text button, as we now do that in two different places. Reviewed By: brecht Differential Revision: http://developer.blender.org/D40
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_handlers.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 03dcf849b7e..4cdff1e9253 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -2580,6 +2580,26 @@ int ui_button_open_menu_direction(uiBut *but)
return 0;
}
+/* Hack for uiList LISTROW buttons to "give" events to overlaying TEX buttons (cltr-clic rename feature & co). */
+static uiBut* ui_but_list_row_text_activate(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event,
+ uiButtonActivateType activate_type)
+{
+ ARegion *ar = CTX_wm_region(C);
+ uiBut *labelbut = ui_but_find_mouse_over_ex(ar, event->x, event->y, true);
+
+ if (labelbut && labelbut->type == TEX) {
+ /* exit listrow */
+ data->cancel = true;
+ button_activate_exit(C, but, data, false, false);
+
+ /* Activate the text button. */
+ button_activate_init(C, ar, labelbut, activate_type);
+
+ return labelbut;
+ }
+ return NULL;
+}
+
/* ***************** events for different button types *************** */
static int ui_do_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
@@ -3528,24 +3548,16 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
static int ui_do_but_LISTROW(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
{
- ARegion *ar = CTX_wm_region(C);
-
if (data->state == BUTTON_STATE_HIGHLIGHT) {
/* hack to pass on ctrl+click and double click to overlapping text
- * editing field for editing list item names */
+ * editing field for editing list item names
+ */
if ((ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS && event->ctrl) ||
(event->type == LEFTMOUSE && event->val == KM_DBL_CLICK))
{
- uiBut *labelbut = ui_but_find_mouse_over_ex(ar, event->x, event->y, true);
-
- if (labelbut && labelbut->type == TEX) {
- /* exit listrow */
- data->cancel = true;
- button_activate_state(C, but, BUTTON_STATE_EXIT);
- button_activate_exit(C, but, data, false, false);
-
- /* enter text editing */
- button_activate_init(C, ar, labelbut, BUTTON_ACTIVATE_TEXT_EDITING);
+ uiBut *labelbut = ui_but_list_row_text_activate(C, but, data, event, BUTTON_ACTIVATE_TEXT_EDITING);
+ if (labelbut) {
+ /* Nothing else to do. */
return WM_UI_HANDLER_BREAK;
}
}
@@ -5573,7 +5585,15 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
if ((data->state == BUTTON_STATE_HIGHLIGHT) || (event->type == EVT_DROP)) {
/* handle copy-paste */
if (ELEM(event->type, CKEY, VKEY) && event->val == KM_PRESS && (event->ctrl || event->oskey)) {
-
+ /* Specific handling for listrows, we try to find their overlapping tex button. */
+ if (but->type == LISTROW) {
+ uiBut *labelbut = ui_but_list_row_text_activate(C, but, data, event, BUTTON_ACTIVATE_OVER);
+ if (labelbut) {
+ but = labelbut;
+ data = but->active;
+ }
+ }
+
ui_but_copy_paste(C, but, data, (event->type == CKEY) ? 'c' : 'v');
return WM_UI_HANDLER_BREAK;
}