Recent

Author Topic: [SOLVED] FormStyle=fsStayOnTop makes form unresponsive  (Read 6682 times)

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
[SOLVED] FormStyle=fsStayOnTop makes form unresponsive
« on: September 15, 2018, 12:32:11 pm »

Not sure how to explain this, so I'll illustrate it based on a test project (attached);


I have a main form (MainForm), which opens when the application opens, as with most Lazarus applications.
On that form I have a button that allows me to open another form (ShowModal), Form2 (just a normal form - default settings).


On Form2 I have yet another button, which allows me to open a 3rd form - Form3.
Form3 has FormStyle set to fsStayOnTop, everything else are the default values.


Because the FormStyle is set to fsStayOnTop (same with fsSystemStayOntop), this form now is not responding to the mouse or the keyboard, not even in the "systemmenu" responds (eg. the "X" to close the window). None of the controls (incl. buttons) on Form3 respond to mouse or keyboard..


Note: When changing Form3.FormStyle to fsNormal; everything is OK. The form just doesn't stay on top (obviously).


However, when adding another button to the first form (MainForm), which then opens yet another form (Form4), also set to fsStayOntop, then everything works as expected. Form4 stays on top, controls respond to mouse an keyboard.


I have tested this example project under Windows and MacOS, and with both of them all forms work as expected. Just under Linux (GTK2), Form3 does not respond to anything, as if the entire form is disabled.


I did report this as a bug, but I'm not sure if there is an "easy" work around for it.
Obviously, I'm also curious if this happens just in my setup (Lazarus 1.9.0 r58991 FPC 3.0.4 x86_64-linux-gtk2).
I've tested this in Linux Mint 19 and the latest KaOS (different kernels, completely clean).
This happens with the regular stable distribution of Lazarus and from SVN.


Any suggestions are welcome ...  :)
« Last Edit: September 16, 2018, 07:43:02 pm by Hansaplast »

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: FormStyle=fsStayOnTop makes form unresponsive
« Reply #1 on: September 15, 2018, 02:09:14 pm »
Most probably it's because you used ShowModal to show tha second form; it "freezes" the rest of the application until the modally shown form closes.

Try using SecondForm.Show and you'll see.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: FormStyle=fsStayOnTop makes form unresponsive
« Reply #2 on: September 16, 2018, 11:14:10 am »

Hi Lucamar!


Awesome find, I did not think of this. :-)
Is this expected behavior in GTK2?
Under Windows and MacOS this works just fine.


I'd like Form2 to stay on top of From1.
Form3 is basically a "help" window, which I'd like to remain visible (on top of Form2) while the user is editing something on Form2. (Form3 would only appear if the user requests it)


I did try playing with the different FormStyles, but it seems GTK can handle only one Form to remain on top, even if I set the Form2.FormStyle=fsStayOnTop and Form3.FormStyle=fsSystemStayOntop. fsSystemStayOntop is not honored on Form3 and wiuth a click Form2 jumps in front of Form3.


Any suggestions for a work around?

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: FormStyle=fsStayOnTop makes form unresponsive
« Reply #3 on: September 16, 2018, 12:33:54 pm »
Without thinking very much, a workaround may be integrating the help in Form2, perhaps in a panel which can be shown/hiden at will?

As to whether the behaviour is expected  in GTK, I really don't know. GTK, or its support in Lazarus, is somewhat quirky about some things so it may well be. You can hava a look at the GTK docs to make sure.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: FormStyle=fsStayOnTop makes form unresponsive
« Reply #4 on: September 16, 2018, 01:03:23 pm »
Thanks Lucamar - your help is much appreciated.


Integration in the form may be the next thing to try I guess.
I'm not a GTK expert either - I'm just writing a program for MacOS, which I'd like to make available (for free) for Windows and Linux as well.


Thanks again!

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: FormStyle=fsStayOnTop makes form unresponsive
« Reply #5 on: September 16, 2018, 01:55:47 pm »

Hi Lucamar!


Awesome find, I did not think of this. :-)
Is this expected behavior in GTK2?
Under Windows and MacOS this works just fine.


I'd like Form2 to stay on top of From1.
set Form2.popupParent := Form1;
or, if my memory serves me right, form2.popupMode := pmAuto;
Form3 is basically a "help" window, which I'd like to remain visible (on top of Form2) while the user is editing something on Form2. (Form3 would only appear if the user requests it)

Form3 needs a higher order than the rest of your forms. That is what stayOnTop was designed for in windows, its your best solution. Just make sure it does not cover up any modal dialogs because you will freeze your application.

Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: FormStyle=fsStayOnTop makes form unresponsive
« Reply #6 on: September 16, 2018, 05:27:08 pm »
I'd like Form2 to stay on top of From1.
set Form2.popupParent := Form1;
or, if my memory serves me right, form2.popupMode := pmAuto;

I didn't know that. Awesome. thanks Taazz.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: FormStyle=fsStayOnTop makes form unresponsive
« Reply #7 on: September 16, 2018, 05:27:16 pm »

Awesome Taaz!
That worked!!
I had never even looked at popupParent before ... all new to me as well!


For others running into issues like this (for this example anyway);


Form1   (in the example project file I called it MainForm)
  formStyle = fsNormal


Call Form2 with Form2.Show; // do not use ShowModal.


Form2
  formStyle = fsNormal
  popupParent = Form1 (which automatically sets popupMode to pmExplicit)


Call Form3 with Form3.Show.


Form3
  formStyle = fsStayOnTop
  popupMode = pmAuto


Now it works the way I was hoping for.
Thanks guys for helping out!
« Last Edit: September 16, 2018, 08:01:10 pm by Hansaplast »

bracara

  • New Member
  • *
  • Posts: 20
Re: [SOLVED] FormStyle=fsStayOnTop makes form unresponsive
« Reply #8 on: November 03, 2018, 10:38:15 pm »
Thanks for this folks - it solved my problem, which was very similar.

My project's main form opens a (modal) preferences form, which opens another form with a progress bar to show it is downloading files. The progress form was set to fsStayonTop but the cancel button on it would not accept input on Linux (I hadn't got as far as trying it on Windows).

I suspected that the problem was related to the modal form and this thread enabled me to fix the problem.

This forum is invaluable!

 

TinyPortal © 2005-2018