Clean up code
Simplify event
This commit is contained in:
@@ -26,7 +26,7 @@ feature
|
|||||||
do
|
do
|
||||||
create textbox1.make ("txtBox1", "1")
|
create textbox1.make ("txtBox1", "1")
|
||||||
create textbox2.make ("txtBox2", "2")
|
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", "")
|
create textbox_result.make ("txtBox3", "")
|
||||||
button1.set_click_event (agent handle_click)
|
button1.set_click_event (agent handle_click)
|
||||||
create panel.make ("panel")
|
create panel.make ("panel")
|
||||||
@@ -37,12 +37,9 @@ feature
|
|||||||
control := panel
|
control := panel
|
||||||
end
|
end
|
||||||
|
|
||||||
handle_click (context: WSF_PAGE_CONTROL)
|
handle_click
|
||||||
do
|
do
|
||||||
if attached {SAMPLE_PAGE} context as sp then
|
textbox_result.set_text (textbox1.text + " + " + textbox2.text + " = " + (textbox1.text.to_integer_16 + textbox2.text.to_integer_16).out)
|
||||||
|
|
||||||
sp.textbox_result.set_text (textbox1.text + " + " + textbox2.text+" = "+ (textbox1.text.to_integer_16+textbox2.text.to_integer_16).out)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
process
|
process
|
||||||
|
|||||||
@@ -40,15 +40,15 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
|||||||
|
|
||||||
feature --EVENT HANDLING
|
feature --EVENT HANDLING
|
||||||
|
|
||||||
set_click_event (e: PROCEDURE [ANY, TUPLE [WSF_PAGE_CONTROL]])
|
set_click_event (e: attached like click_event)
|
||||||
do
|
do
|
||||||
click_event := e
|
click_event := e
|
||||||
end
|
end
|
||||||
|
|
||||||
handle_callback (cname: STRING; event: STRING; page: WSF_PAGE_CONTROL)
|
handle_callback (cname: STRING; event: STRING)
|
||||||
do
|
do
|
||||||
if Current.control_name.is_equal (cname) and attached click_event as cevent then
|
if Current.control_name.is_equal (cname) and attached click_event as cevent then
|
||||||
cevent.call ([page])
|
cevent.call ([])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -68,6 +68,6 @@ feature
|
|||||||
|
|
||||||
text: STRING
|
text: STRING
|
||||||
|
|
||||||
click_event: detachable PROCEDURE [ANY, TUPLE [WSF_PAGE_CONTROL]]
|
click_event: detachable PROCEDURE [ANY, TUPLE []]
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
|||||||
|
|
||||||
feature --EVENT HANDLING
|
feature --EVENT HANDLING
|
||||||
|
|
||||||
handle_callback (cname: STRING; event: STRING; page: WSF_PAGE_CONTROL)
|
handle_callback (cname: STRING; event: STRING)
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -67,14 +67,14 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
|||||||
|
|
||||||
feature --EVENT HANDLING
|
feature --EVENT HANDLING
|
||||||
|
|
||||||
handle_callback (event: STRING; cname: STRING; page: WSF_PAGE_CONTROL)
|
handle_callback (event: STRING; cname: STRING)
|
||||||
do
|
do
|
||||||
if equal (cname, control_name) then
|
if equal (cname, control_name) then
|
||||||
else
|
else
|
||||||
across
|
across
|
||||||
controls as c
|
controls as c
|
||||||
loop
|
loop
|
||||||
c.item.handle_callback (event, cname, page)
|
c.item.handle_callback (event, cname)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ feature
|
|||||||
if attached {JSON_OBJECT} json_parser.parse_json as sp then
|
if attached {JSON_OBJECT} json_parser.parse_json as sp then
|
||||||
control.load_state (sp)
|
control.load_state (sp)
|
||||||
end
|
end
|
||||||
control.handle_callback (control_name, event, Current)
|
control.handle_callback (control_name, event)
|
||||||
create new_states.make
|
create new_states.make
|
||||||
control.read_state (new_states)
|
control.read_state (new_states)
|
||||||
response.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "application/json"]>>)
|
response.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "application/json"]>>)
|
||||||
|
|||||||
@@ -41,16 +41,16 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
|||||||
feature --EVENT HANDLING
|
feature --EVENT HANDLING
|
||||||
|
|
||||||
|
|
||||||
set_change_event (e: PROCEDURE [ANY, TUPLE [WSF_PAGE_CONTROL]])
|
set_change_event (e: attached like change_event)
|
||||||
do
|
do
|
||||||
change_event := e
|
change_event := e
|
||||||
end
|
end
|
||||||
|
|
||||||
handle_callback (cname: STRING; event: STRING; page: WSF_PAGE_CONTROL)
|
handle_callback (cname: STRING; event: STRING)
|
||||||
do
|
do
|
||||||
if Current.control_name.is_equal (cname) and attached change_event as cevent then
|
if Current.control_name.is_equal (cname) and attached change_event as cevent then
|
||||||
if event.is_equal ("change") then
|
if event.is_equal ("change") then
|
||||||
cevent.call ([page])
|
cevent.call ([])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -71,6 +71,6 @@ feature
|
|||||||
|
|
||||||
text: STRING
|
text: STRING
|
||||||
|
|
||||||
change_event: detachable PROCEDURE [ANY, TUPLE [WSF_PAGE_CONTROL]]
|
change_event: detachable PROCEDURE [ANY, TUPLE []]
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user