Page 1 of 1
Dialog - Get Gadget/Window XML Node
Posted: Sat Aug 10, 2013 8:17 am
by schallweller
Is there a way to get the XML Node Pointer from the Gadget/Window?
Something like GetDialogGadgetXMLNode(#Dialog,Gadget$)
So you could add custom attributes to the Gadget that can, for example, be processed in the eventprocedure. Also you could change the color or the appearance in a custom way and anybody could write his own advance dialogfeatures.
Re: Dialog - Get Gadget/Window XML Node
Posted: Sat Aug 10, 2013 10:02 am
by Fred
You can use the XML library command before creating the dialog to do that.
Re: Dialog - Get Gadget/Window XML Node
Posted: Sat Aug 10, 2013 11:27 am
by schallweller
Hmm, I don't know if you understood my request or if i just did not understand your advice.
Example XML (
look at Button1 - attribute: customtext - as example)
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<window name="win_main" width="600" height="400" text="Main Window">
<gridbox columns="2">
<button name="Button1" text="Test 1" onevent="Button1Event()" customtext="The Custom Text" />
<button name="Button2" text="Test 2" />
</gridbox>
</window>
Example PB in my mind
(look at the "fantasy" Runtime Procedure where I try to receive the content of the gadgets "customtext"-Attribute )
Code: Select all
#XML = 0
#Dialog = 0
Runtime Procedure Button1Event()
*GadgetNode = GetDialogGadgetXMLNode(#Dialog,"button1") ; The XMLNode of the Gadget "button1", how can I get it?
Debug GetXMLAttribute(*GadgetNode,"customtext") ; Would show me the string "The Custom Text" of the attribute "customtext"
EndProcedure
If LoadXML(#XML, "dialog.xml")
If XMLStatus(#XML) = #PB_XML_Success
CreateDialog(#Dialog)
If OpenXMLDialog(#Dialog, #XML, "")
HideWindow(DialogWindow(#Dialog), #False)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
EndIf
EndIf
Re: Dialog - Get Gadget/Window XML Node
Posted: Sat Aug 10, 2013 1:25 pm
by erion
Hello,
Modifying the XML sort of defeats the purpose of dialog templates. If you'd like to customize controls at runtime, see dialogGadget. After you got the gadget ID, you can use SetGadgetAttribute, etc, as usual.
Erion
Re: Dialog - Get Gadget/Window XML Node
Posted: Sat Aug 10, 2013 2:18 pm
by schallweller
It's not that I want to modify the Gadget.... it's about for example storing additional data to the gadget. Unknown xml Attributes seem to be ignored.. so i don't see any problem in adding additional attributes to the node. Therefore I only want to know the XML-NODE Address in order to read out the attributes.
Re: Dialog - Get Gadget/Window XML Node
Posted: Sat Aug 10, 2013 2:23 pm
by Fred
Then you can use the XML library commands to locate the node of a given gadget, it should work.
Re: Dialog - Get Gadget/Window XML Node
Posted: Sat Aug 10, 2013 2:32 pm
by schallweller
I think now I got you... you mean for example by iterating recursively through the tree and storing the elements addresses that have a "name" attributes to a map. Ok, I just thought there would be another way. Not that it would be a problem, i was just playing around and thinking about the new feature. The Dialog functions will make many things easier....thanks for that.