PDA

View Full Version : Questions regarding creating windows



Brenn
April 4th, 2012, 11:46
Let me preface this by saying that the immediate need that is driving these questions is that I want to change the behavior of the sidebar menu. I want to make it more dynamic and abandon the windowReferenceControls in favor of string controls (so I don't have to create a bunch of icons). I know I could create text widgets with the windowReference control, however the text widgets don't (that I've found) have the script control over the text color and transparency that you gain with a text based control.

The desktop manager currently uses windowReferenceControls to instance the associated windows. I understand I would have to maintain a table with my string controls for the windowclass and node associated with that menu selection, but what else am I losing in abandoning the windowReferenceControl?

Specifically, does the windowReferenceControl handle the node logic related to client creation of new windows (i.e. Interface.requestNewClientWindow)?

I just feel like I'm missing something about windowReferenceControls. It doesn't seem like creating a template for a string control that does what the windowReferenceControl currently does (as I understand it at least) would be that big of a deal, and things that seem too easy are generally the ones that bite me in the arse...

Moon Wizard
April 5th, 2012, 01:06
Here is a grab bag of information that might help. Let me know if you have any more questions.

* The current sidebar uses a combination of desktop.lua and manager_desktop.lua to layout the sidebar. It sounds like you have already looked at these.

* A windowreferencecontrol has up, down and empty states, which can each have their own icon. When it is clicked, it essentially makes an Interface.openWindow call with the class and database path information from the referencecontrol. That in essence is what a windowreferencecontrol is.

* Widgets do not receive mouse events, and only exist in relation to primary control types, which do receive mouse events.

* Try checking out the 3.5E modifiers window code. It uses a buttoncontrol for the up/down and mouse handling, but uses textwidgets for the button text. This sounds similar to what you are after.

* Also, you could also use a stringcontrol as well, as they handle mouse events also.

* Text widgets do not support explicit text recoloration like stringcontrols do, but you can define a new font with any color you want, that can be assigned to a text widget.

Regards,
JPG

Brenn
April 5th, 2012, 02:46
Thanks and that is exactly what I was looking for. I'm using string controls- I've actually already started the code, but I wanted to make sure I wasn't missing anything before I got too far down the path.

Brenn
April 7th, 2012, 17:26
Ok I've pretty much have the whole thing working, but I believe the windowreference control is doing something different behind the scenes with regards to the client. Here is the code for the template string control that toggles the windows:


local myNodeName = "";
local myClass = "";

function setClass(sClass, sNodeName)
myClass = sClass;
myNodeName = sNodeName;
end

function onClickDown(button, x, y)
return true;
end

function onClickRelease(button, x, y)
local win = Interface.findWindow(myClass, myNodeName);
if win then
if win.isMinimized() then --softclose.
win.bringToFront();
else --window is open, toggle close.
win.close();
end
else --open the window
win = Interface.openWindow(myClass, myNodeName);
end
return true;
end

Now on the host side everything works grand, however on the client side everything works except for those items with nodes associated (i.e. Story, Images, Notes). The menu will not pop a window unless I've first shared a Note or whatever with the client. I can then 'unshare' the note and the client will still be able to open the window (albeit without any items in it). After the unsharing the client is no longer listed as a holder in db.xml, so that doesn't appear to be what is hanging it up.

I've tried using Interface.requestNewClientWindow, but that creates new nodes it does not reference existing ones with the client as a holder.

I've done NodeManager.addWatcher when clients log in, and that works but the first time I create something, such as a new note it is automatically shared with the client. And that does not appear to be required by the Foundation or 3.5/4E rulesets for the story,images and notes nodes, all of which use windowreferencecontrols for the sidebar dock items.

Anyone have any ideas? This should be easy and I'm obviously overlooking something, but I'm befuddled at this point.

Moon Wizard
April 9th, 2012, 20:21
You're right, it does have the capability to create "phantom" database nodes on the client, which is not an exposed functionality right now.

A workaround is to have a hidden windowreferencecontrol field that you can activate on your string press. Plus, it should handle the closetoggle behavior as well.

Regards,
JPG

Brenn
April 10th, 2012, 00:02
You're right, it does have the capability to create "phantom" database nodes on the client, which is not an exposed functionality right now.

A workaround is to have a hidden windowreferencecontrol field that you can activate on your string press. Plus, it should handle the closetoggle behavior as well.

Regards,
JPG

Yeah I had that in the back of my head as a backup, I just didn't want to go there if I didn't have to.

Thanks!