I want to implement a custom draggable asset that can be only dragged horizontally.
Can someone please help me the relevant function that are available within omni.ui or other such libraries?
The inspiration for this feature is the seuqencer tool’s playhead icon on the timeline that is draggable.
It would be very helpful if someone could point to the right documentation, or to a relevant snippet that solves this .
HI @Richard3D , the draggable asset is part of the UI extension, much like the playhead icon on the timeline of the Sequencer Tool. I am attaching the image as a refernce.
The icon that you see in green color is the one I am talking about. Need to move it/drag it in horizontal direction along the custom timeline.
We would recommend you to use ui.Placer. Slider is more complicated in terms of the customized draggable assets.
You can do something like this
with ui.ZStack():
TimelineWidget() # customized timeline
# placer contains the draggable assets of the icon and a label shows the timeline value
placer = ui.Placer(draggable=True, drag_axis=ui.Axis.X, offset_x=400, offset_y=120)
with placer:
with ui.VStack():
ui.Image(...) # the icon
timeline_label = ui.Label("0", style={"color": cl.white})
def set_text(widget, text):
widget.text = text
placer.set_offset_x_changed_fn(lambda o: set_text(timeline_label, str(o))