[Lazarus] TStringGrid and cancelling a modal form

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Mon Mar 12 18:25:57 CET 2018

Running on (Debian) Linux on AMD64 or ARM, Lazarus 1.6.4 and FPC 3.0.2, 
I'm seeing different behaviour depending on whether a program uses Qt or 
GTK2. The program changes the hardware configuration of a mouse 
(Logitech G600) using hidraw, and as such needs to run with root 
privilege (e.g. kdesudo or sudo -E).

On the main form I've got (a tabbed notebook containing multiple 
instances of) a TStringGrid. The OnSelection event invokes a modal form 
(containing nothing of significant complexity) with OK and Cancel 
buttons, and stripped down looks like this:

procedure TFormLG600.StringGridMode1UnshiftedSelection(Sender: TObject; 
aCol, aRow: Integer);

   if ButtonsAndKeys.ShowModal() = mrOk then begin

This is fine if built for Qt, but if built for GTK2 what I see is that 
after the modal form is exited any mouse activity over the grid appears 
to cause an erratic multicell selection and the modal form immediately 
pops up again. This is reproducible if the Cancel button is pressed, and 
in at least some cases after OK.

I've seen indeterminate discussion of this in the foramina, and have 
followed up the indicated wiki pages etc. Does anybody have any 
suggestions, preferably not along the lines of "don't use GTK2" since I 
was thinking of sticking this on Sourceforge and that restriction would 
probably be unpopular?

Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the Lazarus mailing list