Context menus are supported by almost all UI frameworks and most people got used to them. Therefore it’s high time to provide context menus in the YaST Qt UI as well. yast2-qt-2.18.6 offers this feature, packages are available in my build service repository.
In four simple steps YCP programmers can benefit from this new feature:
Create a widget and tell via `opt(`contextMenu) that a ContextMenuActivated Event should be emitted when the user right clicks the widget:
`SelectionBox( `id(`sport), `opt(`notify,`immediate, `contextMenu),
"Open a context menu:",
Wait and analyze events:
event = UI::WaitForEvent( ... );
if ( event["EventReason"]:"" == "ContextMenuActivated" )
Open a context menu. The argument of OpenContextMenu() describes the menu structure:
[ `item(`id(`folder), "&Folder" ),
"&Text File" ),
"&Image" ) ]) ] ));
Analyze the returned `id and trigger an action. An example called ContextMenu.ycp is included in the package yast2-ycp-ui-bindings.
A Context menu provides shortcuts to actions for a certain widget or item. This features improves usability when it’s used properly. Application programmers should avoid making certain features only using context menus because users might not find them.
Please keep in mind that YaST ncurses doesn’t provide context menus. Each operation that is only available via a context menu is useless in YaST ncurses because the user cannot select it.