[Gambas-user] DesktopWindow.Name; Unexpected result

adamnt42 at ...626... adamnt42 at ...626...
Sat Jun 17 13:51:47 CEST 2017


On Sat, 17 Jun 2017 12:19:53 +0200
Gianluigi <bagonergi at ...626...> wrote:

> Sorry but I do not understand the difference;
> From Gambas documentation on DesktopWindow.VisibleName (gb.desktop):
> Returns the window visible name, i.e. the window title as displayed by the
> window manager.
> The visible name may be different from the name, when two or more windows
> have the same name.
> 

Ah! Now I see where your confusion lies...
1) DesktopWindow.Name : "i.e. its title as specified by the application that owns this window."
2) DesktopWindow.VisibleName : " i.e. the window title as displayed by the window manager."

The difference is subtle and not easy to find an example for, but it does happen I can assure you.

You understand how an application sets the Title of a window that it displays, OK? Hence you see the file name in the title for the windows in your output. This is the .Name property value.
Now there are situations where the window manager itself will modify the title for some reason or other.  I cannot think up an example but maybe you have seen somewhere a window title that looked something like "My Window - some info" and if you had two of these open the titles would be something like "My Window - some info:1" and "My Window - some info:2". These titles are set by the Window Manager, from the title supplied by the owning application and for its' own sweet reasons. In other words, it is not easy to "make this happen" as it depends on the window manager in use and its logic for re-titling specific windows.

Now here is the reason for having the two properties.  If you are searching for a specific window by it's expected title, i.e. the application set Title, then exact match searches will fail when the window manager has altered it. So then we use DesktopWindow.Name ... and get a list if there are more than one.  But if we want to act on a specific, re-titled, window then Desktop.Window.VisibleName can be used.

I have said this before, and no doubt will say it again.
Above my desk is a sign that says : "Read EVERY word in the Gambas help page".  I put it up there nearly 10 years ago when I was learning Gambas for the first time and even today I occasionally have to refer to it when I get frustrated by something that I don't understand about Gambas.  I recommend you get a similar sign.  :-)

regards
b






-- 
B Bruen <adamnt42 at ...3379... (sort of)>




More information about the User mailing list