PDA

View Full Version : findWindow() syntax to find a panel?



Toadwart
June 28th, 2007, 09:04
Trying to figure out how to to locate the windowinstance for a panel using the Interface.findWindow function.

Have a panel like so:


<panel name="shortcuts" modes="host">
<class>shortcuts_dm</class>
<bounds>
<anchored>
<left>
<anchor>left</anchor>
<offset>370</offset>
</left>
<top>
<anchor>top</anchor>
<offset>90</offset>
</top>
<bottom>
<anchor>bottom</anchor>
<offset>30</offset>
</bottom>
<size>
<width>67</width>
</size>
</anchored>
</bounds>
</panel>

with class definition:


<windowclass name="shortcuts_dm">
<sizelimits>
<maximum>
<height>1000</height>
</maximum>
</sizelimits>
<sheetdata>
<windowreferencecontrol>
<icon>
<normal>DesktopIconCharacters</normal>
<pressed>DesktopIconCharactersDown</pressed>
</icon>
<bounds>20,0,47,27</bounds>
<class>charactersheetlist</class>
<recordname>charsheet</recordname>
<tooltip>
<text>Characters</text>
</tooltip>
<nodrag />
<closetoggle />
</windowreferencecontrol>
...
</windowclass>


I'd like to find that panel in order to disable the windowreferencecontrol but findWindow doesn't seem to be locating it.

I though this would work since the panel class has no database node but it just gives an "invalid parameters passed to findWindow" error:


Interface.findWindow("shortcuts_dm"), nil);


Also tried:


Interface.findWindow("shortcuts_dm"), "");

and


Interface.findWindow("shortcuts_dm"), "nil");

both of which return nil


Anyone know how to do this?

joshuha
June 28th, 2007, 13:57
Interface.findWindow("shortcuts_dm", ""); should work. I use this all the time for custom windowclass controls not tied to the DB.

Toadwart
June 28th, 2007, 20:03
Cheers Joshua.
Will triple-check my code. Probably some silly mistake like an incorrect uppercase/lowercase character...

Toadwart
September 13th, 2007, 23:13
Bump. I still can't figure out how to use findWindow to find a panel.

e.g. trying to find the chat window:


if Interface.findWindow("chat", "") then
print("found chat");
else
print("couldnt find chat");
end

comes back with "couldnt find chat"...

Works fine for normal windowclasses that are not bound to a datasource but not for classes used for panels. :confused:

Toadwart
September 14th, 2007, 10:43
Aha! Now I see your sneaky bit of :ninja: coding! And I shall make like a :bandit: and :pirate: it for my own nefarious purposes!

Or in english:
The onInit function in chat_chat.lua stores a reference to the chat window (self) within the ChatManager.lua script block. Hence, I can access the chat window from anywhere else by caalling a function I have added to ChatManager.lua! :cool: