diff --git a/demo/src/demo/Demo.yaml b/demo/src/demo/Demo.yaml index aed784e..5f24d95 100644 --- a/demo/src/demo/Demo.yaml +++ b/demo/src/demo/Demo.yaml @@ -17,21 +17,21 @@ views: contentSize: true paddings: [25, 8] text: List - +onPress: "$code:function(_) switcher.change('list_form')" + +onPress: "$code:switcher.change('list_form')" - id: tail_form $type: haxework.gui.ToggleButtonView skin: $r:skin:tab contentSize: true paddings: [25, 8] text: Tail - +onPress: "$code:function(_) switcher.change('tail_form')" + +onPress: "$code:switcher.change('tail_form')" - id: any_form $type: haxework.gui.ToggleButtonView skin: $r:skin:tab contentSize: true paddings: [25, 8] text: Any - +onPress: "$code:function(_) switcher.change('any_form')" + +onPress: "$code:switcher.change('any_form')" - id: switcher $type: haxework.gui.frame.FrameSwitcher skin: $r:skin:border @@ -64,19 +64,19 @@ views: contentSize: true padding: 8 text: green - +onPress: "$code:function(_) Theme.setColor(0x33aa33)" + +onPress: "$code:Theme.setColor(0x33aa33)" - $type: haxework.gui.ButtonView skin: $r:skin:button contentSize: true padding: 8 text: red - +onPress: "$code:function(_) Theme.setColor(0xaa3333)" + +onPress: "$code:Theme.setColor(0xaa3333)" - $type: haxework.gui.ButtonView skin: $r:skin:button contentSize: true padding: 8 text: yellow - +onPress: "$code:function(_) Theme.setColor(0xaaaa33)" + +onPress: "$code:Theme.setColor(0xaaaa33)" rightMargin: 30 - $type: haxework.gui.ButtonView @@ -94,5 +94,4 @@ views: contentSize: true padding: 8 text: Cancel - #+onPress: $this:close - +onPress: "$code:function(_) flash.system.System.exit(0)" + +onPress: "$code:flash.system.System.exit(0)" diff --git a/src/main/haxework/macro/TemplateMacro.hx b/src/main/haxework/macro/TemplateMacro.hx index f7ffc28..fa338ea 100644 --- a/src/main/haxework/macro/TemplateMacro.hx +++ b/src/main/haxework/macro/TemplateMacro.hx @@ -154,7 +154,12 @@ class TemplateMacro { var value = createValue(name, key, Reflect.field(data, key), position, exprs); if (value != null) { if (key.charAt(0) == "+") { - exprs.push(Context.parse('${name}.${key.substr(1)}.connect(${value})', getPosition(position))); + var e:Expr = Context.parse(value, getPosition(position)); + e = switch (e.expr) { + case ECall(_, _): macro function(_) ${e}; + case _: e; + } + exprs.push(macro $p{[name, key.substr(1)]}.connect(${e})); } else { exprs.push(Context.parse('${name}.${key} = ${value}', getPosition(position))); }