Loading of widgets from DML markup and DML Editor in DlangUI

Vadim Lopatin via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Tue Apr 14 01:29:15 PDT 2015


On Friday, 10 April 2015 at 19:26:28 UTC, Jonas Drewsen wrote:
> Cool!
>
> I am not really that much into qml... but isn't much of the 
> power of qml coming from using javascript to do logic and 
> bindings?
>
> Can you do D code stuff in the DML markup to handle that part 
> e.g. by mixin of the DML?
>
> Keep up the good work.
>
> /Jonas

So far, I'm going to implement

* automatic mapping of loaded widgets to member variables (based 
on matching of widget id and variable names, or, possible mixin 
adding of member variables for all of widgets with ids)

* automatic mapping of loaded widget signals to handlers

Mixing in handlers written in D from DML is possible, in some of 
future implementations. So far, I'm not sure that it's better 
than just having external signal handlers automatically mapped, 
e.g. by name.

sample DML:
{
     HorizontalLayout {
         TextWidget { text: "Enter file name:" }
         EditLine {
             id: edFileName

         }
         Button {
             id: btnOpen
             text: "Open"
             click = onBtnOpenClick
         }
     }
}

...
// class members
EditLine _edFileName;
bool onBtnOpenClick(Widget src) {
     window.showMessageBox("Open"d, "File name:"d ~ 
_edFileName.text);
     return true;
}

Member variable `EditLine _edFileName;` could be added 
automatically by mixin, or at least it's value can be initialized 
on load
Signal handler may be assigned either if explicitly defined in 
DML (`click = onBtnOpenClick` means widget click signal should be 
connected to member function onBtnOpenClick) or just found based 
on widget Id and signal name (e.g. if there is widget with 
id="btnOpen" and class method onBtnOpenClick - loader mixin could 
automatically decide to assign this method as signal handler of 
widget (like it's dont in VB).

I'm not sure if alternative definition is better

         Button {
             id: btnOpen
             text: "Open"
             click = { window.showMessageBox("Open"d, "File 
name:"d ~ edFileName.text); }
         }



More information about the Digitalmars-d-announce mailing list