Clean up code

Simplify event
This commit is contained in:
YNH Webdev
2013-08-28 19:43:44 +02:00
parent 595d0c501a
commit e186475a81
6 changed files with 15 additions and 18 deletions

View File

@@ -26,7 +26,7 @@ feature
do
create textbox1.make ("txtBox1", "1")
create textbox2.make ("txtBox2", "2")
button1 := create {WSF_BUTTON_CONTROL}.make ("sample_button1", "SUM")
create button1.make ("sample_button1", "SUM")
create textbox_result.make ("txtBox3", "")
button1.set_click_event (agent handle_click)
create panel.make ("panel")
@@ -37,12 +37,9 @@ feature
control := panel
end
handle_click (context: WSF_PAGE_CONTROL)
handle_click
do
if attached {SAMPLE_PAGE} context as sp then
sp.textbox_result.set_text (textbox1.text + " + " + textbox2.text+" = "+ (textbox1.text.to_integer_16+textbox2.text.to_integer_16).out)
end
textbox_result.set_text (textbox1.text + " + " + textbox2.text + " = " + (textbox1.text.to_integer_16 + textbox2.text.to_integer_16).out)
end
process

View File

@@ -40,15 +40,15 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
feature --EVENT HANDLING
set_click_event (e: PROCEDURE [ANY, TUPLE [WSF_PAGE_CONTROL]])
set_click_event (e: attached like click_event)
do
click_event := e
end
handle_callback (cname: STRING; event: STRING; page: WSF_PAGE_CONTROL)
handle_callback (cname: STRING; event: STRING)
do
if Current.control_name.is_equal (cname) and attached click_event as cevent then
cevent.call ([page])
cevent.call ([])
end
end
@@ -68,6 +68,6 @@ feature
text: STRING
click_event: detachable PROCEDURE [ANY, TUPLE [WSF_PAGE_CONTROL]]
click_event: detachable PROCEDURE [ANY, TUPLE []]
end

View File

@@ -38,7 +38,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
feature --EVENT HANDLING
handle_callback (cname: STRING; event: STRING; page: WSF_PAGE_CONTROL)
handle_callback (cname: STRING; event: STRING)
deferred
end

View File

@@ -67,14 +67,14 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
feature --EVENT HANDLING
handle_callback (event: STRING; cname: STRING; page: WSF_PAGE_CONTROL)
handle_callback (event: STRING; cname: STRING)
do
if equal (cname, control_name) then
else
across
controls as c
loop
c.item.handle_callback (event, cname, page)
c.item.handle_callback (event, cname)
end
end
end

View File

@@ -52,7 +52,7 @@ feature
if attached {JSON_OBJECT} json_parser.parse_json as sp then
control.load_state (sp)
end
control.handle_callback (control_name, event, Current)
control.handle_callback (control_name, event)
create new_states.make
control.read_state (new_states)
response.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "application/json"]>>)

View File

@@ -41,16 +41,16 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
feature --EVENT HANDLING
set_change_event (e: PROCEDURE [ANY, TUPLE [WSF_PAGE_CONTROL]])
set_change_event (e: attached like change_event)
do
change_event := e
end
handle_callback (cname: STRING; event: STRING; page: WSF_PAGE_CONTROL)
handle_callback (cname: STRING; event: STRING)
do
if Current.control_name.is_equal (cname) and attached change_event as cevent then
if event.is_equal ("change") then
cevent.call ([page])
cevent.call ([])
end
end
end
@@ -71,6 +71,6 @@ feature
text: STRING
change_event: detachable PROCEDURE [ANY, TUPLE [WSF_PAGE_CONTROL]]
change_event: detachable PROCEDURE [ANY, TUPLE []]
end