1. wxEuphoria - On hover
- Posted by Steady Jan 10, 2015
- 2195 views
Is there something like a list opening up when a mouse hovers, in a list or in a grid cell.
I am aware that I can click to do an action, but instead of clicking I want to open out another list or do any action as soon as the mouse hovers in the appropriate area.
Thanks in advance.
2. Re: wxEuphoria - On hover
- Posted by buzzo Jan 11, 2015
- 2154 views
You might try MouseTraps ... Defined sub-regions of a window that can generate w32HMouseTrap events.
3. Re: wxEuphoria - On hover
- Posted by ghaberek (admin) Jan 14, 2015
- 2112 views
Is there something like a list opening up when a mouse hovers, in a list or in a grid cell.
I am aware that I can click to do an action, but instead of clicking I want to open out another list or do any action as soon as the mouse hovers in the appropriate area.
You'll need to use the wxEVT_MOTION event to track mouse movements (you'll get a lot of them). Then you can use mouse_event_position() to get the position of the mouse for that event. However, I don't think there are any functions that determine the specific bounds of a cell on screen. Ultimately, I would recommend using a wxGrid with the wxGridCellChoiceEditor column type. See set_col_editor() for details.
You might try MouseTraps ... Defined sub-regions of a window that can generate w32HMouseTrap events.
That's only for Win32Lib, not wxEuphoria. Although it might not be too difficult to reproduce in wxEuphoria. It's really just a low-level event handler for mouse movements.
-Greg
4. Re: wxEuphoria - On hover
- Posted by Steady Jan 14, 2015
- 2097 views
Is there something like a list opening up when a mouse hovers, in a list or in a grid cell.
I am aware that I can click to do an action, but instead of clicking I want to open out another list or do any action as soon as the mouse hovers in the appropriate area.
You'll need to use the wxEVT_MOTION event to track mouse movements (you'll get a lot of them). Then you can use mouse_event_position() to get the position of the mouse for that event. However, I don't think there are any functions that determine the specific bounds of a cell on screen. Ultimately, I would recommend using a wxGrid with the wxGridCellChoiceEditor column type. See set_col_editor() for details.
You might try MouseTraps ... Defined sub-regions of a window that can generate w32HMouseTrap events.
That's only for Win32Lib, not wxEuphoria. Although it might not be too difficult to reproduce in wxEuphoria. It's really just a low-level event handler for mouse movements.
-Greg
Thanks Greg and Buzzo.
I suspected that w32HMouseTrap was only in Win32Lib because there is no documentation for it in wxEuphoria.
I will work on Greg's suggestion. It seems a horrendous task. I suppose I will have to convert all my 15 comboboxes to reside within a grid of 1x15, and then define all the parameters which the mouse might visit to open the comboboxes, and before clicking the combobox should open if I simulate "open combo box" event. That last part might be difficult. I have about 15 comboboxes with 6-17 items in each, at present occupying very little real estate. At one point I did have these 120 or so items displayed nicely in a grid of 15 rows, 20 columns, but that was rejected because it occupied too much real estate.
5. Re: wxEuphoria - On hover
- Posted by ghaberek (admin) Jan 14, 2015
- 2113 views
I will work on Greg's suggestion. It seems a horrendous task. I suppose I will have to convert all my 15 comboboxes to reside within a grid of 1x15, and then define all the parameters which the mouse might visit to open the comboboxes, and before clicking the combobox should open if I simulate "open combo box" event. That last part might be difficult. I have about 15 comboboxes with 6-17 items in each, at present occupying very little real estate. At one point I did have these 120 or so items displayed nicely in a grid of 15 rows, 20 columns, but that was rejected because it occupied too much real estate.
There are functions in wxWidgets for wxComboBox called Popup() and Dismiss() which behave much as you'd expect. In theory, you could trigger a call to Popup() on wxEVT_ENTER_WINDOW and to Dismiss() on wxEVT_LEAVE_WINDOW and that would trigger the dropdown automatically when the mouse hovers over the wxComboBox control. In theory, of course. However, the problem is that these functions were added in wxWidgets 2.9.1 and the latest version of wxEuphoria is still based on the 2.8 series, so they are not currently wrapped in wxEuphoria. I have not been in the business of updating wxEuphoria recently but that should happen sooner than later so I will see if I can get something together soon.
-Greg
6. Re: wxEuphoria - On hover
- Posted by ghaberek (admin) Jan 14, 2015
- 2064 views
I did some cursory testing with wxWidgets 3.0.2 on Windows 7 and it's not looking good for the functionality you've described.
Basically what happens, is that when you call Popup() during the wxEVT_ENTER_WINDOW event, it shows the dropdown as you'd expect. But, the act of calling Popup() also triggers wxEVT_LEAVE_WINDOW because the popup itself is technically a separate window, which immediately closes the dropdown with the call to Dismiss(). This creates an annoying loop with the dropdown opening and closing very rapidly.
If skip calling Dismiss() during the wxEVT_LEAVE_WINDOW event, I get the expected behavior and the dropdown does not close. However, moving the cursor over another combobox does not trigger another wxEVT_ENTER_WINDOW event because the dropdown still has focus.
The ultimate solution may involve tracking the cursor using wxEVT_MOTION on the parent window, using HitTest() to see which combobox is under the cursor, and then showing the dropdown with Popup() if the "current" combobox has changed. Currently, the hit_test() function in wxEuphoria only works on wxListCtrl, wxTreeCtrl, or wxTextCtrl, even though wxWindow supports HitTest() as well.
Yet another thing that would have to be wrapped for this to work. Again, I will see if I can get to that soon.
Here is the code I used to test, if it is of any use to you.
#include <wx/combobox.h> class AutoComboBox : public wxComboBox { public: AutoComboBox( wxWindow* parent, wxWindowID id, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0 ); void OnEnter( wxMouseEvent& event ); void OnLeave( wxMouseEvent& event ); private: wxDECLARE_EVENT_TABLE(); }; wxBEGIN_EVENT_TABLE(AutoComboBox, wxComboBox) EVT_ENTER_WINDOW(AutoComboBox::OnEnter) EVT_LEAVE_WINDOW(AutoComboBox::OnLeave) wxEND_EVENT_TABLE() AutoComboBox::AutoComboBox( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style ) : wxComboBox( parent, id, value, pos, size, 0, NULL, style, wxDefaultValidator, wxComboBoxNameStr ) { wxArrayString items; items.Add( "Apples" ); items.Add( "Bananas" ); items.Add( "Grapes" ); items.Add( "Oranges" ); items.Add( "Pears" ); this->Append( items ); } void AutoComboBox::OnEnter( wxMouseEvent& event ) { this->Popup(); } void AutoComboBox::OnLeave( wxMouseEvent& event ) { this->Dismiss(); }
-Greg
7. Re: wxEuphoria - On hover
- Posted by Steady Jan 15, 2015
- 2033 views
Thanks again Greg. I appreciate your concern and desire to accelerate this implementation.
It is a feature of windows and a lot of application use it for 2-3 level access of lists, without having to click.
My daughter who is not a programmer, but uses a lot of software both on Windows and mac, was not just surprised but horrified when I showed her access to lists and sub-lists based on clicking to open a combobox each time.
I shall continue developing other parts of my software and hope that you will have something available soon.
8. Re: wxEuphoria - On hover
- Posted by ghaberek (admin) Jan 15, 2015
- 2075 views
Thanks again Greg. I appreciate your concern and desire to accelerate this implementation.
It is a feature of windows and a lot of application use it for 2-3 level access of lists, without having to click.
My daughter who is not a programmer, but uses a lot of software both on Windows and mac, was not just surprised but horrified when I showed her access to lists and sub-lists based on clicking to open a combobox each time.
I shall continue developing other parts of my software and hope that you will have something available soon.
That seems to me like a behavior exhibited by a series of menus, not comboboxes. I assume you have a hierarchy of values that depend on the level above them, like Car Make/Model/Year, etc.
I think we may be able to accomplish this by "chaining" one combobox into the next. During the wxEVT_COMMAND_COMBOBOX_SELECTED event (i.e. when a combobox value changes), we can jump to the "next" combobox and show its dropdown immediately. This does still require that we implement Popup() in wxEuphoria. But at least with the code below, you get that automatic "jump" when something is selected.
include wxeu/wxeud.e include std/map.e constant NULL = 0 constant wxID_ANY = -1 constant ID_COMBO1 = new_id(), ID_COMBO2 = new_id(), ID_COMBO3 = new_id(), $ atom frame = create( wxFrame, {NULL, wxID_ANY, "ComboBox", -1, -1, 400, 300} ) atom panel = create( wxPanel, {frame} ) atom combo1 = create( wxComboBox, {panel, ID_COMBO1, "", 10, 10, 200, -1} ) atom combo2 = create( wxComboBox, {panel, ID_COMBO2, "", 10, 40, 200, -1} ) atom combo3 = create( wxComboBox, {panel, ID_COMBO3, "", 10, 70, 200, -1} ) map m_next = map:new() map:put( m_next, combo1, combo2 ) map:put( m_next, combo2, combo3 ) sequence items = { "Apples", "Bananas", "Grapes", "Oranges", "Pears" } for i = 1 to length( items ) do add_item( combo1, items[i] ) add_item( combo2, items[i] ) add_item( combo3, items[i] ) end for procedure ComboBox_onChange( atom this, atom event_type, atom id, atom event ) atom next = map:get( m_next, this, NULL ) if next != NULL then set_focus( next ) -- popup( next ) -- not implemented end if end procedure set_event_handler( combo1, -1, wxEVT_COMMAND_COMBOBOX_SELECTED, routine_id("ComboBox_onChange") ) set_event_handler( combo2, -1, wxEVT_COMMAND_COMBOBOX_SELECTED, routine_id("ComboBox_onChange") ) set_event_handler( combo3, -1, wxEVT_COMMAND_COMBOBOX_SELECTED, routine_id("ComboBox_onChange") ) wxMain( frame )
-Greg
9. Re: wxEuphoria - On hover
- Posted by Steady Jan 15, 2015
- 2059 views
I think wxmenu would work. I do not know how to make it vertical instead of horizontal.
The wxTreectl might also work and work in a vertical way. Where can I find the samples of wxTreectl
10. Re: wxEuphoria - On hover
- Posted by ghaberek (admin) Jan 16, 2015
- 2023 views
I think wxmenu would work. I do not know how to make it vertical instead of horizontal.
To create a submenu, first create a wxMenu object with no parent, then create a new wxMenuItem with the menu as the subMenu parameter.
Here is an example showing:
- how to create a popup menu
- how to create sub-menus
- how to show a popup menu when a button is clicked
Edit: here's a better demo that builds the menus with loops and tracks their values using a map.
include wxeu/wxeud.e include std/map.e constant NULL = 0 constant wxID_ANY = -1 atom frame = create( wxFrame, {NULL, wxID_ANY, "Popup Menu Demo", -1, -1, 400, 300} ) atom panel = create( wxPanel, {frame, wxID_ANY} ) atom button = create( wxButton, {panel, wxID_ANY, "Select", 30, 30, 90, 30} ) atom popup = create( wxMenu, {NULL} ) map m_text = map:new() atom menu, item, subitem, id sequence text for i = 1 to 6 do text = sprintf( "Menu %d", {i} ) menu = create( wxMenu, {NULL} ) item = create( wxMenuItem, {popup, wxID_ANY, text, "", wxITEM_NORMAL, menu} ) for j = 1 to 8 do id = new_id() text = sprintf( "Item %d-%d", {i,j} ) subitem = create( wxMenuItem, {menu, id, text} ) map:put( m_text, id, text ) end for end for procedure button_clicked( atom this, atom event_type, atom id, atom event ) sequence rect = get_rect( button ) show_popup_menu( panel, popup, rect[1], rect[2]+rect[4] ) end procedure set_event_handler( button, wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, routine_id("button_clicked") ) procedure menuitem_clicked( atom this, atom event_type, atom id, atom event ) sequence text = map:get( m_text, id, "unknown" ) message_box( sprintf("You clicked on '%s' (id = %d)", {text,id}), "Popup Menu Demo", wxICON_INFORMATION ) end procedure set_event_handler( popup, wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, routine_id("menuitem_clicked") ) wxMain( frame )
The wxTreectl might also work and work in a vertical way. Where can I find the samples of wxTreectl
There is a wxTreeCtrl and wxListCtrl demo included with wxEuphoria, called tree_list_demo.exw.
-Greg
11. Re: wxEuphoria - On hover
- Posted by Steady Jan 16, 2015
- 1963 views
Thanks again, Greg. I found the demo.
I will work on it for a week or so.
12. Re: wxEuphoria - On hover
- Posted by Steady Jan 20, 2015
- 1903 views
Just to let you know that I am working with wxMenu, etc with some success.
I made to three levels and will me going to the fourth level - and it is all on Hover and seamless.
Thanks again, Greg.