DearPyGui
DearPyGui copied to clipboard
Using item handlers with drag points
Is it possible to use item handlers with drag points? For example, I'd like to be able to hover the mouse over a drag point and use the mouse wheel to trigger some action. Here is a minimal not-working example of what I thought could work using item handlers:
import dearpygui.dearpygui as dpg
dpg.create_context()
def print_val(sender):
print(dpg.get_value(sender))
def print_hover(sender):
print('hover')
with dpg.window(label="Tutorial", width=400, height=400):
with dpg.plot(label="Drag Lines/Points", height=-1, width=-1):
dpg.add_plot_legend()
dpg.add_plot_axis(dpg.mvXAxis, label="x")
dpg.set_axis_limits(dpg.last_item(), -5, 5)
dpg.add_plot_axis(dpg.mvYAxis, label="y")
dpg.set_axis_limits(dpg.last_item(), -5, 5)
dpg.add_drag_point(tag='drag1',label="dpoint1", color=[255, 0, 255, 255], default_value=(1.0, 1.0), callback=print_val)
with dpg.item_handler_registry(tag="handler1") as handler:
dpg.add_item_hover_handler(callback=print_hover)
dpg.bind_item_handler_registry("drag1", "handler1")
dpg.create_viewport(title='Custom Title', width=800, height=600)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
But I get the error:
Exception:
Error: [1000]
Command: bind_item_handler_registry
Item: 26
Label: dpoint1
Item Type: mvAppItemType::mvDragPoint
Message: Item Handler Registry includes inapplicable handler: mvHoverHandler
Is there a way to get the functionality I'm after?
It's not a direct answer to your question, however the list of 'applicable' item types can be consulted in the source code here
This discussion is inactive since March 15. Closing the issue.