awtk/design/default/ui/test_fscript.xml
2022-07-07 10:47:52 +08:00

148 lines
5.7 KiB
XML

<window text="Desktop" anim_hint="htranslate" single_instance="true">
<property name="on:window_open">
print("window_open")
</property>
<property name="on:window_will_open">
print("window_will_open")
</property>
<property name="on:window_close">
print("window_close")
</property>
<property name="on:key_down">
print("keydown:", key, "alt=", alt, "ctrl=", ctrl, "cmd=", cmd, "menu=", menu);
</property>
<property name="on:key_up">
print("keyup:", key, "alt=", alt, "ctrl=", ctrl, "cmd=", cmd, "menu=", menu);
</property>
<property name="on:key_long_press">
print("keyup:", key, "alt=", alt, "ctrl=", ctrl, "cmd=", cmd, "menu=", menu);
</property>
<property name="on:pointer_down">
print("pointerdown:", x, y, "alt=", alt, "ctrl=", ctrl, "cmd=", cmd, "menu=", menu);
</property>
<property name="on:pointer_up">
print("pointerup:", x, y, "alt=", alt, "ctrl=", ctrl, "cmd=", cmd, "menu=", menu);
</property>
<property name="on:click">
print("click:", x, y, "alt=", alt, "ctrl=", ctrl, "cmd=", cmd, "menu=", menu);
</property>
<view name="view" x="0" y="0" w="100%" h="100%" children_layout="default(c=1,r=13,m=5,s=5)">
<label name="label" text="label" />
<edit name="edit" tips="text edit" on:focus="print(focus)" on:blur="print('blur', widget_get('self','value'))"/>
<progress_bar name="bar" text="" value="10" on:value_changed="print(widget_get('self','value'))"/>
<view name="view" x="0" y="0" w="100%" h="100%" children_layout="default(c=2,r=1,m=2,s=2)">
<button focusable="true" focused="true" on:click="open('basic_fscript')" text="Basic" />
<button focusable="true" text="Buttons">
<property name="on:click">
win = open('button_fscript')
assert(!value_is_null(win))
widget_set(win, 'close.text', "Back")
assert(widget_get(win, 'close.text') == "Back");
</property>
</button>
</view>
<button focusable="true" text="Test">
<property name="on:click">
widget_set('parent', 'label.text', 'Hello');
assert(widget_get('parent', 'label.text') == 'Hello');
widget_set('window', 'view.label.text', 'Hello World');
assert(widget_get('window', 'view.label.text') == 'Hello World');
widget_set('self', 'text', 'Test...');
assert(widget_get('self', 'text') == 'Test...');
</property>
</button>
<view name="view" x="0" y="0" w="100%" h="100%" children_layout="default(c=2,r=1,m=2,s=2)">
<button focusable="true" text="Inc">
<property name="on:click">
<![CDATA[
a = widget_lookup('window', 'bar', true)
if(a.value <= 90) {
a.value = a.value + 10
}
]]>
</property>
</button>
<button focusable="true" text="Dec">
<property name="on:click">
<![CDATA[
a = widget_lookup('window', 'bar', true)
if(a.value >= 10) {
a.value = a.value - 10
}
]]>
</property>
</button>
</view>
<view name="view" x="0" y="0" w="100%" h="100%" children_layout="default(c=2,r=1,m=2,s=2)">
<button focusable="true" text="Create">
<property name="on:click">
a = widget_lookup('window', 'foobar', true)
if(value_is_null(a)) {
a = widget_create('label', 'window.view', 0, 0, 0, 0)
assert(!value_is_null(a))
widget_set(a, 'text', 'Dynamic created')
assert(widget_get(a, 'text') == 'Dynamic created')
widget_set(a, 'name', 'foobar')
assert(widget_get(a, 'name') == 'foobar')
} else {
print("foobar exist");
}
</property>
</button>
<button focusable="true" text="Destroy">
<property name="on:click">
a = widget_lookup('window', 'foobar', true)
if(!value_is_null(a)) {
widget_destroy(a)
} else {
print('not found foobar');
}
</property>
</button>
</view>
<view name="view" x="0" y="0" w="100%" h="100%" children_layout="default(c=2,r=1,m=2,s=2)">
<button focusable="true" on:click="close()" text="Close" />
<button focusable="true" on:click="quit()" text="Quit" />
</view>
<view name="view_timer" x="0" y="0" w="100%" h="100%" children_layout="default(c=2,r=1,m=2,s=2)">
<button name="timer" focusable="true" on:click="start_timer(100)" text="Start Timer">
<property name="on:timer">
<![CDATA[
a = widget_lookup('window', 'bar', true)
b = widget_get(a, 'value')
if(b < 100) {
widget_set(a, 'value', b + 1)
} else {
widget_set(a, 'value', 0)
stop_timer()
}
]]>
</property>
</button>
<button focusable="true" on:click="stop_timer('parent.timer')" text="Stop Timer" />
</view>
<view name="view" x="0" y="0" w="100%" h="100%" children_layout="default(c=2,r=1,m=2,s=2)">
<button focusable="true" on:click="reset_timer('window.view.view_timer.timer')" text="Reset Timer" />
<button focusable="true" on:click="modify_timer('window.view.view_timer.timer', 1000)" text="Modify Timer" />
</view>
<view name="view" x="0" y="0" w="100%" h="100%" children_layout="default(c=2,r=1,m=2,s=2)">
<button focusable="true" on:click="suspend_timer('window.view.view_timer.timer')" text="Suspend Timer" />
<button focusable="true" on:click="resume_timer('window.view.view_timer.timer')" text="Resume Timer" />
</view>
<view name="view" x="0" y="0" w="100%" h="100%" children_layout="default(c=2,r=1,m=2,s=2)">
<button focusable="true" on:click="back()" text="Back" />
<button focusable="true" on:click="back_to_home()" text="Back To Home" />
</view>
</view>
</window>