conrod icon indicating copy to clipboard operation
conrod copied to clipboard

Context Menu (aka ClickDownMenu) Draft

Open libfud opened this issue 10 years ago • 10 comments
trafficstars

There should be something like a Contextual trait, where right clicking on a widget which implements it reveals a context menu. I think this shares some overlap with a drop down menu.

libfud avatar Apr 21 '15 16:04 libfud

I think this might even be best as its own Widget. A user could provide either a specific clickable area, or the ID of a widget that can be clicked to activate it. Usage could be something like:

RightClickMenu::new(some_menu)
    .click_area(position, dimensions) // A user could either use this
    .click_widget(SOME_WIDGET_ID) // or this.
    .react(...)
    .set(MY_CLICK_MENU, ui);

mitchmindtree avatar Jul 11 '15 13:07 mitchmindtree

It would be cool if a user could specify which mouse button activates the menu. Perhaps ClickDownMenu is a better name.

mitchmindtree avatar Jul 11 '15 13:07 mitchmindtree

There should be a single Menu type/trait which can be shared between this and the Menu/ToolBar #417 and perhaps even the DropDownList (could be changed to DropDownMenu).

mitchmindtree avatar Jul 11 '15 13:07 mitchmindtree

in existing UI frameworks, both are rendered by creating a floating titlebarless window which is able to extend outside of the main window.

flying-sheep avatar Aug 27 '15 15:08 flying-sheep

GTK3 applications using client side decoration actually draw the vast majority of popup menus in the actual application window instead of in a floating one. Electron applications do this as well (but that's because they simply can't make floating windows, I think).

agraven avatar Jun 13 '19 08:06 agraven

Interesting! Do they detect if the menu would fit into the window boundaries and only create a floating window if it doesn’t?

flying-sheep avatar Jun 18 '19 07:06 flying-sheep

Most applications like this change which side of the cursor the menu appears on, usually the menu is position so the cursor is at its top-left, but this is changed to bottom or right corner if necessary.

agraven avatar Jun 28 '19 16:06 agraven

Sure, but what if you have a very small parent window or a very long menu? Will it still render in the window (with scrollbars or so) or will it pop out as its own window?

flying-sheep avatar Jun 30 '19 10:06 flying-sheep

It'll stay inside the window.

agraven avatar Jul 03 '19 10:07 agraven

@flying-sheep yes unfortunately conrod will have the same restriction as GTK in this sense (at least for widgets that are generic across platforms). In our case, conrod_core does not have ownership over the windowing context or know anything about it - it just receives input events and outputs widget primitives for rendering and widget events for updating state.

That said, you might be able to implement a popup style menu for a specific windowing backend (e.g. winit) - it would require a custom widget implementation and might be better off as a downstream crate. It may even be possible to make a generic one that worked with windowing from different platforms, but this would likely involve much greater design considerations.

mitchmindtree avatar Jul 03 '19 13:07 mitchmindtree