Preference: option to use OS-Key to emulate MMB
Alt-LMB is used in quite a few areas now, see T69323 using OS-Key allows these conflicts to be avoided. Currently disabled for WIN32, since it conflicts with the start menu.
This commit is contained in:
parent
2e97d50d2d
commit
d596a6368c
|
@ -169,7 +169,10 @@ def load():
|
|||
keyconfig_data = blender_default.generate_keymaps(
|
||||
blender_default.Params(
|
||||
select_mouse=kc_prefs.select_mouse,
|
||||
use_mouse_emulate_3_button=prefs.inputs.use_mouse_emulate_3_button,
|
||||
use_mouse_emulate_3_button=(
|
||||
prefs.inputs.use_mouse_emulate_3_button and
|
||||
prefs.inputs.mouse_emulate_3_button_modifier == 'ALT'
|
||||
),
|
||||
spacebar_action=kc_prefs.spacebar_action,
|
||||
v3d_tilde_action=kc_prefs.v3d_tilde_action,
|
||||
use_select_all_toggle=kc_prefs.use_select_all_toggle,
|
||||
|
|
|
@ -53,7 +53,10 @@ def load():
|
|||
keyconfig_data = blender_default.generate_keymaps(
|
||||
blender_default.Params(
|
||||
select_mouse=kc_prefs.select_mouse,
|
||||
use_mouse_emulate_3_button=prefs.inputs.use_mouse_emulate_3_button,
|
||||
use_mouse_emulate_3_button=(
|
||||
prefs.inputs.use_mouse_emulate_3_button and
|
||||
prefs.inputs.mouse_emulate_3_button_modifier == 'ALT'
|
||||
),
|
||||
spacebar_action='SEARCH',
|
||||
use_select_all_toggle=True,
|
||||
use_gizmo_drag=False,
|
||||
|
|
|
@ -1479,12 +1479,17 @@ class USERPREF_PT_input_mouse(PreferencePanel, Panel):
|
|||
return (prefs.active_section == 'INPUT')
|
||||
|
||||
def draw_props(self, context, layout):
|
||||
import sys
|
||||
prefs = context.preferences
|
||||
inputs = prefs.inputs
|
||||
|
||||
flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
|
||||
|
||||
flow.prop(inputs, "use_mouse_emulate_3_button")
|
||||
if sys.platform[:3] != "win":
|
||||
rowsub = flow.row()
|
||||
rowsub.active = inputs.use_mouse_emulate_3_button
|
||||
rowsub.prop(inputs, "mouse_emulate_3_button_modifier")
|
||||
flow.prop(inputs, "use_mouse_continuous")
|
||||
flow.prop(inputs, "use_drag_immediately")
|
||||
flow.prop(inputs, "mouse_double_click_time", text="Double Click Speed")
|
||||
|
|
|
@ -606,7 +606,8 @@ typedef struct UserDef {
|
|||
/** #eUserPref_PrefFlag preferences for the preferences. */
|
||||
char pref_flag;
|
||||
char savetime;
|
||||
char _pad4[4];
|
||||
char mouse_emulate_3_button_modifier;
|
||||
char _pad4[3];
|
||||
/** FILE_MAXDIR length. */
|
||||
char tempdir[768];
|
||||
char fontdir[768];
|
||||
|
@ -1240,6 +1241,11 @@ typedef enum eUserpref_TempSpaceDisplayType {
|
|||
USER_TEMP_SPACE_DISPLAY_WINDOW,
|
||||
} eUserpref_TempSpaceDisplayType;
|
||||
|
||||
typedef enum eUserpref_EmulateMMBMod {
|
||||
USER_EMU_MMB_MOD_ALT = 0,
|
||||
USER_EMU_MMB_MOD_OSKEY = 1,
|
||||
} eUserpref_EmulateMMBMod;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -424,6 +424,17 @@ static void rna_userdef_timecode_style_set(PointerRNA *ptr, int value)
|
|||
}
|
||||
}
|
||||
|
||||
static int rna_UserDef_mouse_emulate_3_button_modifier_get(PointerRNA *ptr)
|
||||
{
|
||||
# if !defined(WIN32)
|
||||
UserDef *userdef = ptr->data;
|
||||
return userdef->mouse_emulate_3_button_modifier;
|
||||
# else
|
||||
UNUSED_VARS(ptr);
|
||||
return USER_EMU_MMB_MOD_ALT;
|
||||
# endif
|
||||
}
|
||||
|
||||
static PointerRNA rna_UserDef_view_get(PointerRNA *ptr)
|
||||
{
|
||||
return rna_pointer_inherit_refine(ptr, &RNA_PreferencesView, ptr->data);
|
||||
|
@ -5487,6 +5498,21 @@ static void rna_def_userdef_input(BlenderRNA *brna)
|
|||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_keyconfig_reload_update");
|
||||
|
||||
static const EnumPropertyItem mouse_emulate_3_button_modifier[] = {
|
||||
{USER_EMU_MMB_MOD_ALT, "ALT", 0, "Alt", ""},
|
||||
{USER_EMU_MMB_MOD_OSKEY, "OSKEY", 0, "OS-Key", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
prop = RNA_def_property(srna, "mouse_emulate_3_button_modifier", PROP_ENUM, PROP_NONE);
|
||||
/* Only needed because of WIN32 inability to support the option. */
|
||||
RNA_def_property_enum_funcs(prop, "rna_UserDef_mouse_emulate_3_button_modifier_get", NULL, NULL);
|
||||
RNA_def_property_enum_items(prop, mouse_emulate_3_button_modifier);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Emulate 3 Button Modifier", "Hold this modifier to emulate the middle mouse button");
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_keyconfig_reload_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_emulate_numpad", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_NONUMPAD);
|
||||
RNA_def_property_ui_text(
|
||||
|
|
|
@ -4210,19 +4210,31 @@ static void wm_eventemulation(wmEvent *event, bool test_only)
|
|||
if (U.flag & USER_TWOBUTTONMOUSE) {
|
||||
|
||||
if (event->type == LEFTMOUSE) {
|
||||
if (event->val == KM_PRESS && event->alt) {
|
||||
event->type = MIDDLEMOUSE;
|
||||
event->alt = 0;
|
||||
short *mod = (
|
||||
#if !defined(WIN32)
|
||||
(U.mouse_emulate_3_button_modifier == USER_EMU_MMB_MOD_OSKEY) ? &event->oskey :
|
||||
&event->alt
|
||||
#else
|
||||
/* Disable for WIN32 for now because it accesses the start menu. */
|
||||
&event->alt
|
||||
#endif
|
||||
);
|
||||
|
||||
if (!test_only) {
|
||||
emulating_event = MIDDLEMOUSE;
|
||||
if (event->val == KM_PRESS) {
|
||||
if (*mod) {
|
||||
*mod = 0;
|
||||
event->type = MIDDLEMOUSE;
|
||||
|
||||
if (!test_only) {
|
||||
emulating_event = MIDDLEMOUSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event->val == KM_RELEASE) {
|
||||
/* only send middle-mouse release if emulated */
|
||||
if (emulating_event == MIDDLEMOUSE) {
|
||||
event->type = MIDDLEMOUSE;
|
||||
event->alt = 0;
|
||||
*mod = 0;
|
||||
}
|
||||
|
||||
if (!test_only) {
|
||||
|
|
Loading…
Reference in New Issue