Added new macro "file.select_execute", by default mapped to LMB doubleclick in file selector.
This selects+opens the file under the mouse pointer, can be customised. This somewhat fixes [#20727] MMB don't load .blend from the file browser
This commit is contained in:
		@@ -86,6 +86,7 @@ int ED_fileselect_layout_offset(FileLayout* layout, int x, int y);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void ED_fileselect_layout_tilepos(FileLayout* layout, int tile, int *x, int *y);
 | 
					void ED_fileselect_layout_tilepos(FileLayout* layout, int tile, int *x, int *y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void ED_operatormacros_file(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* ED_FILES_H */
 | 
					#endif /* ED_FILES_H */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,6 +42,7 @@
 | 
				
			|||||||
#include "ED_anim_api.h"
 | 
					#include "ED_anim_api.h"
 | 
				
			||||||
#include "ED_armature.h"
 | 
					#include "ED_armature.h"
 | 
				
			||||||
#include "ED_curve.h"
 | 
					#include "ED_curve.h"
 | 
				
			||||||
 | 
					#include "ED_fileselect.h"
 | 
				
			||||||
#include "ED_gpencil.h"
 | 
					#include "ED_gpencil.h"
 | 
				
			||||||
#include "ED_markers.h"
 | 
					#include "ED_markers.h"
 | 
				
			||||||
#include "ED_mesh.h"
 | 
					#include "ED_mesh.h"
 | 
				
			||||||
@@ -115,6 +116,7 @@ void ED_spacetypes_init(void)
 | 
				
			|||||||
	ED_operatormacros_mesh();
 | 
						ED_operatormacros_mesh();
 | 
				
			||||||
	ED_operatormacros_node();
 | 
						ED_operatormacros_node();
 | 
				
			||||||
	ED_operatormacros_object();
 | 
						ED_operatormacros_object();
 | 
				
			||||||
 | 
						ED_operatormacros_file();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* called in wm.c */
 | 
					/* called in wm.c */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -567,7 +567,7 @@ int file_exec(bContext *C, wmOperator *unused)
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	if(sfile->op) {
 | 
						if(sfile->op) {
 | 
				
			||||||
		wmOperator *op= sfile->op;
 | 
							wmOperator *op= sfile->op;
 | 
				
			||||||
		
 | 
						
 | 
				
			||||||
		sfile->op = NULL;
 | 
							sfile->op = NULL;
 | 
				
			||||||
		RNA_string_set(op->ptr, "filename", sfile->params->file);
 | 
							RNA_string_set(op->ptr, "filename", sfile->params->file);
 | 
				
			||||||
		BLI_strncpy(name, sfile->params->dir, sizeof(name));
 | 
							BLI_strncpy(name, sfile->params->dir, sizeof(name));
 | 
				
			||||||
@@ -1090,3 +1090,13 @@ void FILE_OT_delete(struct wmOperatorType *ot)
 | 
				
			|||||||
	ot->poll= file_delete_poll; /* <- important, handler is on window level */
 | 
						ot->poll= file_delete_poll; /* <- important, handler is on window level */
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void ED_operatormacros_file(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						wmOperatorType *ot;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						ot= WM_operatortype_append_macro("FILE_OT_select_execute", "Select and Execute", OPTYPE_UNDO|OPTYPE_REGISTER);
 | 
				
			||||||
 | 
						WM_operatortype_macro_define(ot, "FILE_OT_select");
 | 
				
			||||||
 | 
						WM_operatortype_macro_define(ot, "FILE_OT_execute");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -381,8 +381,9 @@ void file_keymap(struct wmKeyConfig *keyconf)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	/* keys for main area */
 | 
						/* keys for main area */
 | 
				
			||||||
	keymap= WM_keymap_find(keyconf, "File Browser Main", SPACE_FILE, 0);
 | 
						keymap= WM_keymap_find(keyconf, "File Browser Main", SPACE_FILE, 0);
 | 
				
			||||||
	WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_PRESS, 0, 0);
 | 
						WM_keymap_add_item(keymap, "FILE_OT_select_execute", LEFTMOUSE, KM_DBL_CLICK, 0, 0);
 | 
				
			||||||
	kmi = WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
 | 
						WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_CLICK, 0, 0);
 | 
				
			||||||
 | 
						kmi = WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_CLICK, KM_SHIFT, 0);
 | 
				
			||||||
	RNA_boolean_set(kmi->ptr, "extend", 1);
 | 
						RNA_boolean_set(kmi->ptr, "extend", 1);
 | 
				
			||||||
	WM_keymap_add_item(keymap, "FILE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
 | 
						WM_keymap_add_item(keymap, "FILE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
 | 
				
			||||||
	WM_keymap_add_item(keymap, "FILE_OT_select_border", BKEY, KM_PRESS, 0, 0);
 | 
						WM_keymap_add_item(keymap, "FILE_OT_select_border", BKEY, KM_PRESS, 0, 0);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user