on_gui_click drag & drop support
Posted: Mon Aug 21, 2017 8:28 pm
Long description:
Currently on_gui_click only supports "conventional" clicking, i.e. if the <button down> and <button up> event occur above the same gui element. If the mouse is moved inbetween those two events - i.e. in a circle back to the button - that movement is ignored, and if they happen above different gui elements (i.e. the player holds a mouse button down above an element, drags somewhere else and then releases the mouse button, the event is not fired at all.) then the event is not raised at all. Left Mouse Button clicks do even already seem to have "drag and drop" compatible rendering in that the GuiElement that recives <button down> continues to be rendered with it's clicked_graphical_set style even if the cursor is moved off the button, while right/middle click dragged buttons revert to their default style when the cursor does no longer hover them even if the button is still hold down. Full drag-and-drop style guis would require an event raised for every gui element that the mouse cursor passes over while the mouse button is being held down, containing both the original element, and the hovered over element, and a final event when then mouse button is released. Partial drop-and-drag support would be possible if only the final event was raised.
Short description:
Either extend on_gui_click or introduce a new event on_gui_drag that reports event.button_down_element in combination with either event.button_up_element or event.cursor_hover_element.
Usecase:
Any GUI element where the player needs to reorder a list of elements, this could be for example a research queue, priorities for different inventories to be accessed or a list of ore fields that are being monitored.
Currently on_gui_click only supports "conventional" clicking, i.e. if the <button down> and <button up> event occur above the same gui element. If the mouse is moved inbetween those two events - i.e. in a circle back to the button - that movement is ignored, and if they happen above different gui elements (i.e. the player holds a mouse button down above an element, drags somewhere else and then releases the mouse button, the event is not fired at all.) then the event is not raised at all. Left Mouse Button clicks do even already seem to have "drag and drop" compatible rendering in that the GuiElement that recives <button down> continues to be rendered with it's clicked_graphical_set style even if the cursor is moved off the button, while right/middle click dragged buttons revert to their default style when the cursor does no longer hover them even if the button is still hold down. Full drag-and-drop style guis would require an event raised for every gui element that the mouse cursor passes over while the mouse button is being held down, containing both the original element, and the hovered over element, and a final event when then mouse button is released. Partial drop-and-drag support would be possible if only the final event was raised.
Short description:
Either extend on_gui_click or introduce a new event on_gui_drag that reports event.button_down_element in combination with either event.button_up_element or event.cursor_hover_element.
Usecase:
Any GUI element where the player needs to reorder a list of elements, this could be for example a research queue, priorities for different inventories to be accessed or a list of ore fields that are being monitored.