I have a piece of code that associates some actions with an EV_COMBO_BOX, such that typing a string (a search key) and hitting return should run a search on an EV_RICH_TEXT control; if the key is found, the control gains focus, and the matching text is highlighted. The code is as follows.
make
do
-- create controls
create ev_root_container
create ev_search_combo
-- connect controls
ev_root_container.extend (ev_search_combo)
-- set up events
ev_search_combo.select_actions.extend (agent select_item_from_search_key)
ev_search_combo.return_actions.extend (agent find_item_by_key)
end
ev_search_combo: EV_COMBO_BOX
In the debugger I can verify that this logic works correctly, and at some point, the text is shown highlighted in the rich text pane.
However, further processing occurs on the EV_COMBO_BOX, such that focus is returned to the combo box, and the text selection in the rich text disappears.
When I debug, I discover that there is event processing for the class EV_INTERNAL_COMBO_FIELD_IMP on_key_down, which first calls EV_COMBO_BOX.on_key_down (which is what calls my routine, i.e. does the intended work) as 'parent', and then calls EV_INTERNAL_COMBO_FIELD_IMP.on_key_down, performing 'default processing'. Apparently, 'default processing' for this is to grab focus again, and select the typed in text.
THis is EV_INTERNAL_COMBO_FIELD_IMP.on_key_down - you can see it invokes parent.on_key_down (starred), where parent will be the EV_COMBO_BOX_IMP:
on_key_down (virtual_key, key_data: INTEGER_32)
-- Executed when a key is pressed.
-- We verify that there is indeed a command to avoid
-- the creation of an object for nothing.
-- (export status {NONE})
require -- from WEL_WINDOW
exists: exists
do
if not (virtual_key = {WEL_VK_CONSTANTS}.vk_down or virtual_key = {WEL_VK_CONSTANTS}.vk_up) then
parent.increment_level;
parent.on_key_down (virtual_key, key_data) *******
if parent.has_return_value then
set_message_return_value (parent.message_return_value)
end
if not parent.default_processing then
disable_default_processing
end;
parent.decrement_level
end
end
This exits, and we end up in WEL_DISPATCHER at the starred line:
if window.exists then
debug ("win_dispatcher")
print ("After look at windows table ")
print (window.generating_type);
Io.put_new_line
end;
window.increment_level
need_decrement := True
Result := window.process_message (hwnd, msg, wparam, lparam)
if window.has_return_value then ************
returned_value := window.message_return_value
has_return_value := window.has_return_value
end
if window.default_processing then
Result := window.call_default_window_procedure (hwnd, msg, wparam, lparam) ++++++++++++++
end
This falls through to the line marked with ++++, which causes focus to return to the combo box.
THere is no obvious mechanism that I can find that allows the action of hitting Return in the combo box to result just in doing the intended work and leaving focus in the intended place (a text pane).
Does anyone know a solution?