Fix multi control

Use multi control in example
This commit is contained in:
YNH Webdev
2013-08-28 11:04:54 +02:00
parent f14ea29636
commit b72e6871e8
4 changed files with 56 additions and 22 deletions

View File

@@ -21,22 +21,33 @@ create
feature
initialize_controls
local
panel: WSF_MULTI_CONTROL
do
button := create {WSF_BUTTON_CONTROL}.make ("sample_button", "I'm a button")
button.set_click_event(agent handle_click)
control := button
button1 := create {WSF_BUTTON_CONTROL}.make ("sample_button1", "I'm a button")
button1.set_click_event (agent handle_click)
button2 := create {WSF_BUTTON_CONTROL}.make ("sample_button2", "I'm a button2")
button2.set_click_event (agent handle_click)
create panel.make ("panel")
panel.add_control (button1)
panel.add_control (button2)
control := panel
end
handle_click(context: WSF_PAGE_CONTROL)
do
if attached {SAMPLE_PAGE} context as sp then
sp.button.set_text("Hello World! (Ueeee)")
handle_click (context: WSF_PAGE_CONTROL)
do
if attached {SAMPLE_PAGE} context as sp then
sp.button1.set_text ("Hello World! (Ueeee)")
sp.button2.set_text ("Hi btn2")
end
end
end
process
do
end
button: WSF_BUTTON_CONTROL
button1: WSF_BUTTON_CONTROL
button2: WSF_BUTTON_CONTROL
end

View File

@@ -5,10 +5,10 @@ trigger_callback = (control_name,event)->
event: event
cache: no
.done (new_states)->
states = new_states
#Update all classes
for name,state of states
controls[name].update(state)
for name,state of new_states
controls[name]?.update(state)
states = new_states
return
class WSF_CONTROL
@@ -46,5 +46,6 @@ for name,state of states
#get control type
type = $el.data('type')
#create class
controls[name]=new typemap[type](name,$el)
if type? and typemap[type]?
controls[name]=new typemap[type](name,$el)

View File

@@ -12,12 +12,14 @@
},
cache: false
}).done(function(new_states) {
var name, state, states;
states = new_states;
for (name in states) {
state = states[name];
controls[name].update(state);
var name, state, states, _ref;
for (name in new_states) {
state = new_states[name];
if ((_ref = controls[name]) != null) {
_ref.update(state);
}
}
states = new_states;
});
};
@@ -76,7 +78,9 @@
state = states[name];
$el = $('[data-name=' + name + ']');
type = $el.data('type');
controls[name] = new typemap[type](name, $el);
if ((type != null) && (typemap[type] != null)) {
controls[name] = new typemap[type](name, $el);
}
}
}).call(this);