make Alt-KeyPress (hopefully) work on windows by manually building the Mask values

This commit is contained in:
Stefan Schippers 2020-09-07 09:34:41 +02:00
parent ac911ca1f1
commit 30335ce30a
3 changed files with 25 additions and 2 deletions

View File

@ -1439,12 +1439,16 @@ int callback(int event, int mx, int my, KeySym key,
mx_save = mx; my_save = my; /* 20171218 */
mx_double_save=mousex_snap;
my_double_save=mousey_snap;
if(semaphore<2) { /* 20160425 */
/* useless code ? 20200905 */
/* if(semaphore<2) {
rebuild_selected_array();
if(lastselected==0) ui_state &=~SELECTION;
}
} */
select_object(mousex, mousey, 0, 0);
rebuild_selected_array();
if(lastselected==0) ui_state &=~SELECTION;
}
else if(button==Button2 && (state == 0)) {
pan2(BEGIN, mx, my);

View File

@ -1339,6 +1339,16 @@ int Tcl_AppInit(Tcl_Interp *inter)
set_grid(0); /* set default value specified in xschemrc as 'grid' else CADGRID */
} /* if(has_x) */
dbg(1, "Tcl_AppInit(): done X init\n");
/* pass to tcl values of Alt, Shift, COntrol key masks so bind Alt-KeyPress events will work for windows */
#ifndef __unix__
my_snprintf(tmp, S(tmp), "%d", Mod1Mask);
tclsetvar("Mod1Mask", tmp);
my_snprintf(tmp, S(tmp), "%d", ShiftMask);
tclsetvar("ShiftMask", tmp);
my_snprintf(tmp, S(tmp), "%d", ControlMask);
tclsetvar("ControlMask", tmp);
#endif
/* END X INITIALIZATION */
init_done=1; /* 20171008 moved before option processing, otherwise xwin_exit will not be invoked */

View File

@ -2925,6 +2925,15 @@ proc build_windows {} {
}
bind .drw <ButtonRelease> {xschem callback %T %x %y 0 %b 0 %s}
# on Windows Alt key mask is reported as 131072 (1<<17) so build masks manually with values passed from C code
if {$::OS == "Windows" } {
bind .drw <Alt-KeyPress> {puts xxx; xschem callback %T %x %y %N 0 0 [expr $Mod1Mask]}
bind .drw <Control-Alt-KeyPress> {xschem callback %T %x %y %N 0 0 [expr $ShiftMask + $Mod1Mask]}
bind .drw <Shift-Alt-KeyPress> {xschem callback %T %x %y %N 0 0 9 [expr $ControlMask + $Mod1Mask]}
}
bind .drw <KeyPress> {xschem callback %T %x %y %N 0 0 %s}
bind .drw <KeyPress> {xschem callback %T %x %y %N 0 0 %s}
bind .drw <KeyRelease> {xschem callback %T %x %y %N 0 0 %s} ;# 20161118
bind .drw <Motion> {xschem callback %T %x %y 0 0 0 %s}