Recent

Author Topic: Linux: must click twice StringGrid  (Read 2306 times)

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Linux: must click twice StringGrid
« 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.
« Last Edit: January 28, 2020, 02:30:31 pm by lainz »

Handoko

  • Hero Member
  • *****
  • Posts: 5129
  • My goal: build my own game engine using Lazarus
Re: Linux: must click twice StringGrid
« Reply #1 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
« Last Edit: January 28, 2020, 08:14:51 am by Handoko »

Handoko

  • Hero Member
  • *****
  • Posts: 5129
  • My goal: build my own game engine using Lazarus
Re: Linux: must click twice StringGrid
« Reply #2 on: January 28, 2020, 08:10:47 am »
#2

Handoko

  • Hero Member
  • *****
  • Posts: 5129
  • My goal: build my own game engine using Lazarus
Re: Linux: must click twice StringGrid
« Reply #3 on: January 28, 2020, 08:11:06 am »
#3

Handoko

  • Hero Member
  • *****
  • Posts: 5129
  • My goal: build my own game engine using Lazarus
Re: Linux: must click twice StringGrid
« Reply #4 on: January 28, 2020, 08:11:20 am »
#4

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: Linux: must click twice StringGrid
« Reply #5 on: January 28, 2020, 11:45:29 am »
Eh, I think only source files would be sufficient. No need for executable binary.

Handoko

  • Hero Member
  • *****
  • Posts: 5129
  • My goal: build my own game engine using Lazarus
Re: Linux: must click twice StringGrid
« Reply #6 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:
« Last Edit: January 28, 2020, 12:39:29 pm by Handoko »

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Linux: must click twice StringGrid
« Reply #7 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.


Handoko

  • Hero Member
  • *****
  • Posts: 5129
  • My goal: build my own game engine using Lazarus
Re: Linux: must click twice StringGrid
« Reply #8 on: January 28, 2020, 01:59:08 pm »
Good to know that wasn't bug in TStringGrid.

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Linux: must click twice StringGrid
« Reply #9 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.
« Last Edit: January 28, 2020, 02:31:32 pm by lainz »

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Linux: must click twice StringGrid
« Reply #10 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.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Linux: must click twice StringGrid
« Reply #11 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