[Lazarus] TStringGrid and cancelling a modal form

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Mon Mar 12 20:01:45 CET 2018

On 12/03/18 18:15, zeljko wrote:
> On 03/12/2018 06:25 PM, Mark Morgan Lloyd via Lazarus wrote:
>> 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);
>> begin
>> {...}
>>    if ButtonsAndKeys.ShowModal() = mrOk then begin
>> {...}
>>    end
>> end;
>> 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?
> hmm, try LCLIntf.SetCapture(0) after closing modal form , just to 
> isolate capture problems.

Like this?

}  end

;  LCLIntf.SetCapture(0)

end { TFormLG600.StringGridMode1UnshiftedSelection } ;

No obvious change- what should I be looking for?

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