I have been turning a %gr region from a static “repository” for graphics into an interactive system.
In this region, I have a need for various types of mouse clicks, and for popup menus. Eventually, I found what I wanted in “enhanced popup menus”. Firstly, what I think is a bug. When defining the format string for an enhanced popup menu, if the first item is greyed out, Clearwin complains if the –gr is followed by a comma, e.g. as in:
FMT = ‘[-gr,Delete, …
and will only accept
FMT = ‘[-grDelete …
Anywhere else, and the comma IS needed.
Secondly, to make the enhanced popup menus work in a %gr region, full_mouse_input is required. Now I have discovered that full-mouse_input isn’t a nice thing to switch on. On my fairly high-spec system, it makes the detection of ordinary simple clicks seem sluggish and ragged. Not every click is detected, and this leads to mistakes being made. Everything I programmed – except enhanced popup menus – works much more smoothly with full_mouse_input switched off, i.e. not specified. Unfortunately, it seems that this cannot be switched on / off at will. I consider full_mouse_input to be my bête noir.
Consider the range of problems I have had, and the workarounds I have found, and the nature of the underlying problem becomes clear - eventually.
- Parameters passed to a subroutine become undefined. Workaround – send them through COMMON.
- MAX and MIN intrinsic functions stop working. Workaround – of the type IF (A .LT. B) B=A
- Mouse clicks appear not always to be detected. I have a facility where clicking on the edges of my %gr where I have drawn rulers causes the plot to be scaled differently. Without full_mouse_input – perfect. With full_mouse_input about 1 in 5 of the clicks is missed.
- The fourth clue lies in how I struggled to implement click’n’drag (I have actually given up). I couldn’t reliably detect mouse button release. I am, of course, using the recommended route of
CLEARWIN_STRING@('CALLBACK_REASON') and CLEARWIN_INFO@ (‘whatever’)
Interestingly, I found when trying to work with a code that Paul sent, that he uses call get_mouse_info@ (x1,y1,nstat), and definitely, this wouldn’t work reliably when mixed with the approach I am using.
- I have also found that when full_mouse_input is enabled, the behaviour of the full width/height crosshair cursor (as produced by set_graphics_selection@(3)) is noticeably different and erratic. For example, it leaves a “ghost” set of crosshairs at the initial position – but not always. At one stage I managed to get the cross point of the cross hairs to show an XOR circle with a dot in the middle, although that seems to have disappeared now. Bizarre.
I have tried to implement enhanced popup menus. This is where I found the –gr comma bug described above. I found the idea of an enhanced popup menu with a single callback function not particularly well described in the online help file. More to the point, I found it difficult to know what happened after CALL DISPLAY_POPUP_MENU@ (). I eventually concluded that program control transferred to the callback routine associated with the enhanced popup menu, or to the start of the original callback for %gr, but unless I followed CALL DISPLAY_POPUP_MENU@ with
GR_CALLBACK = 1 ! where this is the name of the callback function RETURN
I got erratic behaviour, and I certainly can’t account for that.
Also not described in the help file is what is supposed to happen if one ignores the popup menu and clicks elsewhere on the screen. In this situation, one gets a visit to the %gr region callback, and not the callback that services the popup menu. Obvious in retrospect, but not at first (and not while puzzling out whether –gr should be followed by a comma or not!).