Skip to content

Commit b1967e6

Browse files
committed
SF: Workaround for Igor not changing subwindow focus on right click
There is a bug, where Igor doe snot change the focus to a subwindow when right clicked. This prevents that the clicked window name can be retrieved on the basis of the currently active window. WM suggested a workaround where the last right clicked window is stored in a window hook and then used in the menu handler. This commit implements this workaround.
1 parent 64ee6ae commit b1967e6

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

Packages/MIES/MIES_GlobalStringAndVariableAccess.ipf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,3 +815,9 @@ threadsafe Function/S GetZeroMQXOPCallInfo()
815815

816816
return GetSVARAsString(GetMiesPath(), "ZeroMQXOPCallInfo", initialValue = ZeroMQ_INFO_UNDEFINED)
817817
End
818+
819+
/// @brief Returns the last right clicked sweep formula display (plot/table) window
820+
Function/S GetSweepFormulaLastRightClickedDisplayWindow()
821+
822+
return GetSVARAsString(GetSweepFormulaPath(), "LastRightClickedDisplayWindow", initialValue = "")
823+
End

Packages/MIES/MIES_SweepFormula.ipf

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ Function SF_PutFormulasToClipboard()
5454

5555
string table, txt, jsonTxt, formula
5656

57-
table = GetCurrentWindow()
57+
table = ROStr(GetSweepFormulaLastRightClickedDisplayWindow())
58+
ASSERT(!IsEmpty(table), "Expected window name")
5859

5960
jsonTxt = GetUserData(table, "", SF_UDATA_TABLEFORMULAS)
6061
if(!IsEmpty(jsonTxt))
@@ -619,7 +620,7 @@ static Function/S SF_NewSweepFormulaBaseWindow(string templateName, string graph
619620
NewPanel/N=$win/K=1/W=(150, 400, 1000, 700)
620621
elseif(winType == WINTYPE_TABLE)
621622
Edit/N=$win/K=1/W=(150, 400, 1000, 700)
622-
SF_AddTableExtras(S_name)
623+
SF_AddTableExtrasSub(S_name)
623624
else
624625
FATAL_ERROR("Unsupported window type")
625626
endif
@@ -631,11 +632,16 @@ static Function/S SF_NewSweepFormulaBaseWindow(string templateName, string graph
631632
return win
632633
End
633634

634-
static Function SF_AddTableExtras(string win)
635+
static Function SF_AddTableExtrasSub(string win)
635636

636637
SetWindow $win, tooltipHook(sfTableTooltip)=SF_TableTooltipHook
637638
End
638639

640+
static Function SF_AddTableExtrasMain(string win)
641+
642+
SetWindow $win, hook(sfTableGetWindowName)=SF_TableWindowHook
643+
End
644+
639645
static Function [WAVE/T plotGraphs, WAVE/WAVE infos] SF_PreparePlotter(string winNameTemplate, string graph, variable winDisplayMode, variable numGraphs)
640646

641647
variable i, guidePos, restoreCursorInfo
@@ -677,12 +683,15 @@ static Function [WAVE/T plotGraphs, WAVE/WAVE infos] SF_PreparePlotter(string wi
677683
win = winNameTemplate + num2istr(i)
678684
plotGraphs[i][%GRAPH] = SF_NewSweepFormulaBaseWindow(win, graph, winType = WINTYPE_GRAPH)
679685
win = winNameTemplateTable + num2istr(i)
680-
plotGraphs[i][%TABLE] = SF_NewSweepFormulaBaseWindow(win, graph, winType = WINTYPE_TABLE)
686+
winTable = SF_NewSweepFormulaBaseWindow(win, graph, winType = WINTYPE_TABLE)
687+
SF_AddTableExtrasMain(winTable)
688+
plotGraphs[i][%TABLE] = winTable
681689
endfor
682690
elseif(winDisplayMode == SF_DM_SUBWINDOWS)
683691

684692
win = SF_NewSweepFormulaBaseWindow(winNameTemplate, graph)
685693
winTable = SF_NewSweepFormulaBaseWindow(winNameTemplateTable, graph)
694+
SF_AddTableExtrasMain(winTable)
686695

687696
// now we have an open panel without any subwindows
688697

@@ -710,7 +719,7 @@ static Function [WAVE/T plotGraphs, WAVE/WAVE infos] SF_PreparePlotter(string wi
710719
Display/HOST=$win/FG=(customLeft, $guideName1, customRight, $guideName2)/N=$("Graph" + num2str(i))
711720
plotGraphs[i][%GRAPH] = win + "#" + S_name
712721
Edit/HOST=$winTable/FG=(customLeft, $guideName1, customRight, $guideName2)/N=$("Table" + num2str(i))
713-
SF_AddTableExtras(winTable + "#" + S_name)
722+
SF_AddTableExtrasSub(winTable + "#" + S_name)
714723
plotGraphs[i][%TABLE] = winTable + "#" + S_name
715724
endfor
716725
endif
@@ -2486,3 +2495,19 @@ Function SF_TableTooltipHook(STRUCT WMTooltipHookStruct &s)
24862495

24872496
return hookResult
24882497
End
2498+
2499+
Function SF_TableWindowHook(STRUCT WMWinHookStruct &s)
2500+
2501+
switch(s.eventCode)
2502+
case EVENT_WINDOW_HOOK_MOUSEDOWN:
2503+
if(s.eventMod & WINDOW_HOOK_EMOD_RIGHTCLICK)
2504+
SVAR win = $GetSweepFormulaLastRightClickedDisplayWindow()
2505+
win = s.winName
2506+
endif
2507+
break
2508+
default:
2509+
break
2510+
endswitch
2511+
2512+
return 0
2513+
End

0 commit comments

Comments
 (0)