Lazarus

Programming => General => Topic started by: lainz on January 28, 2020, 01:10:15 am

Title: Linux: must click twice StringGrid
Post by: lainz on January 28, 2020, 01:10:15 am
Hi, I have a StringGrid with an OnClick event, it works fine. The problem is when I call a ShowModal form, then closing it with a button ModalResult = mrOk, and then I try to click the StrinGrid, the OnClick event is not fired, I must click two times in order to the event to fire.

This only works like that on Linux Mint, on Windows it works fine.

I'm cross-compiling 32 bit linux app from Windows. The app is using Gtk2.

Any event that is not being fired that makes the grid elements clickable? The most weird is that the header zone always works fine, I can click the StringGrid headers always, the problem is in the normal grid elements.
Title: Re: Linux: must click twice StringGrid
Post by: Handoko on January 28, 2020, 08:09:25 am
I cannot reproduce your issue. Below is my demo source code and the binary compiled using Lazarus 2.0.6 GTK2 Ubuntu Mate 64-bit.

Because the binary is 3.2 MB, it had to be compressd as 7z file and split into 4 files (and recompressed them) to be able to upload to the forum. You will need some skills to open it.  :D
Title: Re: Linux: must click twice StringGrid
Post by: Handoko on January 28, 2020, 08:10:47 am
#2
Title: Re: Linux: must click twice StringGrid
Post by: Handoko on January 28, 2020, 08:11:06 am
#3
Title: Re: Linux: must click twice StringGrid
Post by: Handoko on January 28, 2020, 08:11:20 am
#4
Title: Re: Linux: must click twice StringGrid
Post by: Cyrax on January 28, 2020, 11:45:29 am
Eh, I think only source files would be sufficient. No need for executable binary.
Title: Re: Linux: must click twice StringGrid
Post by: Handoko on January 28, 2020, 12:35:44 pm
Eh, I think only source files would be sufficient. No need for executable binary.

Because lainz said the issue happened when cross-compiled from Windows. So I provide the binary direct compiled from Linux.

And this is the source without binary, if anyone interested:
Title: Re: Linux: must click twice StringGrid
Post by: lainz on January 28, 2020, 01:50:43 pm
Thanks Handoko for the demo, it's really good. I grabbed the source and cross compiled.

I can't reproduce with the demo, so it's something particular with the showmodal form I'm calling... because I tested with other modal forms in the application and I can replicate only with one in particular.

Title: Re: Linux: must click twice StringGrid
Post by: Handoko on January 28, 2020, 01:59:08 pm
Good to know that wasn't bug in TStringGrid.
Title: Re: Linux: must click twice StringGrid
Post by: lainz on January 28, 2020, 02:26:28 pm
I solved the problem.

In that particular modal form, the button that closes it had MouseDown event instead of MouseClick.

@Handoko, if you change in the Form2 the ButtonClick event by OnMouseDown to close the modal form, I can replicate the problem in your demo.
Title: Re: Linux: must click twice StringGrid
Post by: lainz on February 06, 2020, 10:39:09 pm
Again with this bug, this is a strange bug with the StringGrid, the problem is related to the Focus or ActiveControl, to solve we must put focus to something inside the modal form before closing it, else the StringGrid is not usable anymore.

In other words, in the modified demo that uses MouseDown instead of Click, we must focus something, the button or some other control before closing the modal.
Title: Re: Linux: must click twice StringGrid
Post by: winni on February 06, 2020, 11:19:58 pm
Hi!

I can confirm that there are problems with mouse events in the StringGrid.

From memory, 6 month ago:
I had - because of strange behaviour with mouseclicks  - all 3 events connected:
click, up and down.

What I figured out: if OnClick is questioned then OnMouseUp will never be performed.
OnMouseClick "eats"  that event.

Talking about Lazarus 2.06, gtk2

Winni
TinyPortal © 2005-2018