Dialog - Get Gadget/Window XML Node

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
schallweller
New User
New User
Posts: 4
Joined: Sat Aug 10, 2013 8:11 am

Dialog - Get Gadget/Window XML Node

Post 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.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Dialog - Get Gadget/Window XML Node

Post by Fred »

You can use the XML library command before creating the dialog to do that.
schallweller
New User
New User
Posts: 4
Joined: Sat Aug 10, 2013 8:11 am

Re: Dialog - Get Gadget/Window XML Node

Post 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
erion
Enthusiast
Enthusiast
Posts: 128
Joined: Sun Jan 24, 2010 11:12 pm

Re: Dialog - Get Gadget/Window XML Node

Post 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
To see a world in a grain of sand,
And a heaven in a wild flower,
Hold infinity in the palm of your hand,
And eternity in an hour.

- W. B.

Visit my site, also for PureBasic goodies http://erion.tdrealms.com
schallweller
New User
New User
Posts: 4
Joined: Sat Aug 10, 2013 8:11 am

Re: Dialog - Get Gadget/Window XML Node

Post 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.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Dialog - Get Gadget/Window XML Node

Post by Fred »

Then you can use the XML library commands to locate the node of a given gadget, it should work.
schallweller
New User
New User
Posts: 4
Joined: Sat Aug 10, 2013 8:11 am

Re: Dialog - Get Gadget/Window XML Node

Post 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.
Post Reply