Forum > Cocoa

Have form to stay on top of the app

(1/1)

d4eva:
Is there way to have the form to be on top of the application only, and not the system?
If I set FormStyle to  fsStayOnTop, the form stays on top of the app, but it also stays on top of other windows, if I they are moved on the app.
It works fine on Windows, i.e. the form is only kept on top of the app, but no the whole OS.

I'm using Lazarus 2.2.2. MacOS Monterey 12.0.1 (also tried on Mac Mini M1).
I attached the image on how it looks. I'd prefer the form2 to be below the Finder but still on top of the app.

derek.john.evans:
Same thing happens on the Raspberry Pi (GTK).

But, there is a comment in the CocoaWSForms unit (Near the array FormStyleToHideOnDeactivate)

--- Quote --- Window levels make the form always stay on top, so if it is supposed to stay on top of the app only, then a workaround is to hide it while the app is deactivated
--- End quote ---

The GTK implementation seems to treat fsStayOnTop and fsSystemStayOnTop as the same, and uses the function gtk_window_set_keep_above().


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---fsAllStayOnTop = [fsStayOnTop, fsSystemStayOnTop];gtk_window_set_keep_above({%H-}PGtkWindow(AForm.Handle),      GBoolean(AFormStyle in fsAllStayOnTop))
If you google gtk_window_set_keep_above, it seems that the function is to be removed (?)

https://discourse.gnome.org/t/gtk-4-how-to-replace-gtk-window-set-keep-above-and-gtk-window-set-keep-below/3550

Anyway, I tried using TApplicationProperties and this code, which kinda seems to work. It may work for you, but I'd do a _lot_ of testing.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TFormMain.ApplicationPropertiesActivate(Sender: TObject);begin  FormLog.FormStyle := fsStayOnTop;end; procedure TFormMain.ApplicationPropertiesDeactivate(Sender: TObject);begin  FormLog.FormStyle := fsNormal;end;      

MarkMLl:
With the caveat that I'm not a Mac user, but I think that this is very much dependant on the "Window Manager" part of the OS's GUI which in modern parlance is roughly equivalent to "desktop environment".

As such, the behaviour might vary depending on which desktop has been selected on a platform- e.g. the RPi or most systems based on X11- which allows it to be selected at login.

It might possibly be worth investigating the various dockable extensions, which might be safer than relying on OS facilities ** being portable and consistent.

** Hints passed from the Window Manager to the widget set (e.g. GTK) affecting the app's visual presentation, and requests from the widget set that the Window Manager handle the content of a window in a particular way.

MarkMLl

d4eva:

--- Quote from: derek.john.evans on June 06, 2022, 02:14:57 am ---
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TFormMain.ApplicationPropertiesActivate(Sender: TObject);begin  FormLog.FormStyle := fsStayOnTop;end; procedure TFormMain.ApplicationPropertiesDeactivate(Sender: TObject);begin  FormLog.FormStyle := fsNormal;end;      

--- End quote ---

Thanks. This kinda worked. I also added OnActivate/Deactivate handlers to the Form2.

Navigation

[0] Message Index

Go to full version