Skip to content

Commit

Permalink
feat: add right-click select support (toggle via add-on preferences)
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm authored Mar 22, 2024
1 parent 962d227 commit 7e7aad4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
8 changes: 7 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ class NDPreferences(AddonPreferences):
default=False,
)

enable_right_click_select: BoolProperty(
name="Enable Right Click Select",
default=False,
)

enable_deprecated_features: BoolProperty(
name="Compatibility Mode",
default=False,
Expand Down Expand Up @@ -463,7 +468,8 @@ def draw_general(self, box):
"utils_collection_name",
"use_fast_booleans",
"recon_poly_solidify",
"recon_poly_inscribed"]
"recon_poly_inscribed",
"enable_right_click_select"]

for pref in general_prefs:
column = box.column(align=True)
Expand Down
10 changes: 8 additions & 2 deletions lib/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,15 @@ def capture_modifier_keys(cls, event=None, mouse_x=0):
cls.key_step_down = detected(event, {'WHEELDOWNMOUSE'}) or pressed(event, {'DOWN_ARROW'}) or pressed(event, {'LEFT_ARROW'})

cls.key_confirm = clicked(event, {'LEFTMOUSE'}) or pressed(event, {'SPACE', 'RET', 'NUMPAD_ENTER'})
cls.key_left_click = detected(event, {'LEFTMOUSE'})

if get_preferences().enable_right_click_select:
cls.key_select = detected(event, {'RIGHTMOUSE'})
cls.key_cancel = pressed(event, {'ESC'})
else:
cls.key_select = detected(event, {'LEFTMOUSE'})
cls.key_cancel = clicked(event, {'RIGHTMOUSE'}) or pressed(event, {'ESC'})

cls.key_confirm_alternative = pressed(event, {'SPACE', 'RET', 'NUMPAD_ENTER'})
cls.key_cancel = clicked(event, {'RIGHTMOUSE'}) or pressed(event, {'ESC'})

cls.key_movement_passthrough = detected(event, {'MIDDLEMOUSE'}) or (has(event) and event.alt and event.type in {'LEFTMOUSE', 'RIGHTMOUSE'}) or (has(event) and event.type.startswith('NDOF'))

Expand Down
2 changes: 1 addition & 1 deletion replicate/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def modal(self, context, event):
if self.geometry_mode and not self.geometry_ready:
return self.complete_geometry_mode(context)

elif self.key_left_click and self.geometry_mode and not self.geometry_ready:
elif self.key_select and self.geometry_mode and not self.geometry_ready:
return {'PASS_THROUGH'}

elif self.key_confirm:
Expand Down
2 changes: 1 addition & 1 deletion sketch/geo_lift.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def modal(self, context, event):

return {'PASS_THROUGH'}

elif self.key_left_click:
elif self.key_select:
return {'PASS_THROUGH'}

elif get_preferences().enable_experimental_features and self.key_undo:
Expand Down
2 changes: 1 addition & 1 deletion sketch/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def do_modal(self, context, event):
self.stage = 1
self.dirty = True

if self.stage == 0 and self.key_left_click:
if self.stage == 0 and self.key_select:
return {'PASS_THROUGH'}

if self.key_cancel:
Expand Down
2 changes: 1 addition & 1 deletion sketch/view_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def modal(self, context, event):
elif self.key_confirm_alternative:
return self.finish(context)

elif self.key_left_click:
elif self.key_select:
return {'PASS_THROUGH'}

elif self.key_movement_passthrough:
Expand Down

0 comments on commit 7e7aad4

Please sign in to comment.