arsd.minigui_xml

A small extension module to arsd.minigui that adds functions for creating widgets and windows from short XML descriptions.

If you choose to use this, it will require arsd.dom to be compiled into your project too.

import arsd.minigui_xml;
Window window = createWindowFromXml(`
	<MainWindow>
		<Button label="Hi!" />
	</MainWindow>
`);
More...

Public Imports

arsd.minigui
public import arsd.minigui;
Undocumented in source.

Members

Classes

Event (from arsd.minigui)
class Event via public import arsd.minigui : Event;

Represents an event that is currently being processed.

Functions

createWindowFromXml
Window createWindowFromXml(string xml)
createWindowFromXml
Window createWindowFromXml(Document document)
makeWidgetFromString
Widget makeWidgetFromString(string xml, Widget parent)
miniguiWidgetFromXml
Widget miniguiWidgetFromXml(Element element, Widget parent)
miniguiWidgetFromXml
ParseContinue miniguiWidgetFromXml(Element element, Widget parent, Widget w)

Detailed Description

To add custom widgets to the minigui_xml factory, you need to register them with FIXME.

You can attach some events right in the XML using attributes. The attribute names are onEVENTNAME or ondirectEVENTNAME and the values are one of the following three value types:

$(LIST * If it starts with &, it is a delegate you need to register using the FIXME function.

* If it starts with (, it is a string passed to the arsd.dom.querySelector function to get an element reference

* Otherwise, it tries to call a script function (if scripting is available). )

Keep in mind For example, to make a page widget that changes based on a drop down selection, you may:

<DropDownSelection onchange="$(+PageWidget).setCurrentTab">
	<option>Foo</option>
	<option>Bar</option>
</DropDownSelection>
<PageWidget name="mypage">
	<!-- contents elided -->
</PageWidget>

That will create a select widget that when it changes, it will look for the next PageWidget sibling (that's the meaning of +PageWidget, see css selector syntax for more) and call its setCurrentTab method.

Since the function knows setCurrentTab takes an integer, it will automatically pull the intValue member out of the event and pass it to the method.

The given XML is the same as the following D:

auto select = new DropDownSelection(parent);
select.addOption("Foo");
select.addOption("Bar");
auto page = new PageWidget(parent);
page.name = "mypage";

select.addEventListener("change", (Event event)
{
	page.setCurrentTab(event.intValue);
});

Meta