在变量的值改变时,控件属性被动跟着变;
控件属性变动时,变量值被动跟着变;
有点像vue.js,在某些情况下会有用.
import win.ui;
/*DSG{{*/
var winform = win.form(text="简码编程";right=759;bottom=469)
winform.add(
button={cls="button";text="修改变量";left=345;top=22;right=479;bottom=64;z=2};
edit={cls="edit";left=31;top=24;right=336;bottom=67;edge=1;multiline=1;z=1};
editLog={cls="edit";left=30;top=80;right=737;bottom=445;edge=1;hscroll=1;multiline=1;vscroll=1;z=3}
)
/*}}*/
var age = "";
//时钟
import win.timer
var timer = win.timer( winform );
timer.setInterval(100)
timer.enable();
timer.onTimer = function(hwnd,msg,id,tick){
timer.disable()
if(winform.edit.text != age){
winform.edit.text = age;
winform.editLog.print("age="+age);
}
timer.enable();
}
winform.edit.oncommand = function(id,event){
if(event == 0x300/*_EN_CHANGE*/){
timer.disable()
age = winform.edit.text;
winform.editLog.print("age="+age);
timer.enable();
}
}
winform.button.oncommand = function(id,event){
age = age + "a";
}
winform.show()
win.loopMessage();