translate MouseWheel modifier key (ctrl/shift/no modifier) remappings via replace_key into Tcl8.7+ MouseWheel equivalents.

This commit is contained in:
stefan schippers 2026-06-09 10:34:36 +02:00
parent e85792aee7
commit 80c58e0c9b
2 changed files with 73 additions and 6 deletions

View File

@ -2196,6 +2196,7 @@ static int handle_mouse_wheel(int event, int mx, int my, KeySym key, int button,
waves_callback(event, mx, my, key, button, aux, state);
return 1;
}
/* zoom out */
view_unzoom(CADZOOMSTEP);
return 0;
}
@ -2204,6 +2205,7 @@ static int handle_mouse_wheel(int event, int mx, int my, KeySym key, int button,
waves_callback(event, mx, my, key, button, aux, state);
return 1;
}
/* zoom in */
view_zoom(CADZOOMSTEP);
return 0;
}
@ -2213,6 +2215,7 @@ static int handle_mouse_wheel(int event, int mx, int my, KeySym key, int button,
waves_callback(event, mx, my, key, button, aux, state);
return 1;
}
/* pan to the right; move schematic to left */
xctx->xorigin+=-CADMOVESTEP*xctx->zoom/2.;
draw();
redraw_w_a_l_r_p_z_rubbers(1);
@ -2222,16 +2225,20 @@ static int handle_mouse_wheel(int event, int mx, int my, KeySym key, int button,
waves_callback(event, mx, my, key, button, aux, state);
return 1;
}
/* pan to the left; move schematic to right */
xctx->xorigin-=-CADMOVESTEP*xctx->zoom/2.;
draw();
redraw_w_a_l_r_p_z_rubbers(1);
}
else if(button==Button4 && (state & ControlMask) && !(state & Button2Mask)) {
/* pan down; move schematic up */
xctx->yorigin+=-CADMOVESTEP*xctx->zoom/2.;
draw();
redraw_w_a_l_r_p_z_rubbers(1);
}
else if(button==Button5 && (state & ControlMask) && !(state & Button2Mask)) {
/* pan up; move schematic down */
xctx->yorigin-=-CADMOVESTEP*xctx->zoom/2.;
draw();
redraw_w_a_l_r_p_z_rubbers(1);

View File

@ -9950,7 +9950,7 @@ proc show_bindkeys {} {
}
proc set_bindings {topwin} {
global env has_x OS autofocus_mainwindow
global env has_x OS autofocus_mainwindow replace_key
###
### Tk event handling
###
@ -9978,14 +9978,74 @@ global env has_x OS autofocus_mainwindow
bind $topwin <Expose> "if {{%W} eq {$topwin}} {xschem callback %W %T %x %y 0 %w %h %s}"
# transform mousewheel events into button4/5 events
if {[info tclversion] > 8.7} {
bind $topwin <MouseWheel> {
if {%D > 0} {
xschem callback %W 4 %x %y 0 4 0 %s
if {[info tclversion] >= 8.7} {
set zoom_state 0
set vert_pan_state 4
set horiz_pan_state 1
# transform mouse wheel modifier key remapping into MouseWheel equivalents
if {[info exist replace_key(Button-4)]} {
if {[regexp {Control} $replace_key(Button-4)]} {
set zoom_state 4
} elseif {[regexp {Shift} $replace_key(Button-4)]} {
set zoom_state 1
} else {
xschem callback %W 4 %x %y 0 5 0 %s
set zoom_state 0
}
}
if {[info exist replace_key(Shift-Button-4)]} {
if {[regexp {Control} $replace_key(Shift-Button-4)]} {
set horiz_pan_state 4
} elseif {[regexp {Shift} $replace_key(Shift-Button-4)]} {
set horiz_pan_state 1
} else {
set horiz_pan_state 0
}
}
if {[info exist replace_key(Control-Button-4)]} {
if {[regexp {Control} $replace_key(Control-Button-4)]} {
set vert_pan_state 4
} elseif {[regexp {Shift} $replace_key(Control-Button-4)]} {
set vert_pan_state 1
} else {
set vert_pan_state 0
}
}
bind $topwin <MouseWheel> "
# puts \"MouseWheel: %D\"
if {%D > 0} {
# zoom in
xschem callback %W 4 %x %y 0 4 0 $zoom_state
} else {
# zoom out
xschem callback %W 4 %x %y 0 5 0 $zoom_state
}
"
bind $topwin <Shift-MouseWheel> "
# puts \"Shift-MouseWheel: %D\"
if {%D > 0} {
# pan to the right; move schematic to left
xschem callback %W 4 %x %y 0 4 0 $horiz_pan_state
} else {
# pan to the left; move schematic to right
xschem callback %W 4 %x %y 0 5 0 $horiz_pan_state
}
"
bind $topwin <Control-MouseWheel> "
# puts \"Ctrl-MouseWheel: %D\"
if {%D > 0} {
# pan down; move schematic up
xschem callback %W 4 %x %y 0 4 0 $vert_pan_state
} else {
# pan up; move schematic down
xschem callback %W 4 %x %y 0 5 0 $vert_pan_state
}
"
}
bind $topwin <Double-Button-1> "xschem callback %W -3 %x %y 0 %b 0 %s"