MauiKit Controls

ContextualMenu.qml
1import QtQuick.Controls
2
3/**
4 * @inherit QtQuick.Controls.Menu
5 * @brief A convergent contextual menu that adapats to the screen size and device input method.
6 *
7 * <a href="https://doc.qt.io/qt-6/qml-qtquick-controls-menu.html">This controls inherits from QQC2 Menu, to checkout its inherited properties refer to the Qt Docs.</a>
8 *
9 * @image html Misc/contextualmenu.png "The two displays modes"
10 *
11 * @code
12 * Button
13 * {
14 * text: "Click Me!"
15 * onClicked: _contextualMenu.show()
16 *
17 * Maui.ContextualMenu
18 * {
19 * id: _contextualMenu
20 *
21 * title: "Menu Title"
22 * titleIconSource: "folder"
23 *
24 * Action
25 * {
26 * text: "Action1"
27 * icon.name: "love"
28 * }
29 *
30 * Action
31 * {
32 * text: "Action2"
33 * icon.name: "folder"
34 * }
35 *
36 * MenuSeparator {}
37 *
38 * MenuItem
39 * {
40 * text: "Action3"
41 * icon.name: "actor"
42 * }
43 *
44 * MenuItem
45 * {
46 * text: "Action4"
47 * icon.name: "anchor"
48 * }
49 * }
50 * }
51 * @endcode
52 *
53 * @section notes Notes
54 *
55 * This control will depend on using the Maui Style, for the Menu to have the neded properties.
56 * The properties of the Menu control form the style are unique to Maui, and obscure the documentation of its functionality, this is done to support thoe properties to also the regular QQC2 Menu control.
57 *
58 * The obscured properties are the following:
59 * - title ContextualMenu::title
60 * - titleImageSource ContextualMenu::titleImageSource
61 * - titleIconSource ContextualMenu::titleIconSource
62 *
63 * There is also the readonyl property `responsive` which indicates if the menu is being shown in a "responsibe" manner. Resposinve is assigned to mobile devices, and it is positioned in the bottom part of the screen, while on desktop mode the menu popups from where it has been invoked from.
64 *
65 * <a href="https://invent.kde.org/maui/mauikit/-/blob/qt6-2/examples/ContextualMenu.qml">You can find a more complete example at this link.</a>
66 */
67Menu
68{
69 id: control
70
71 /**
72 * @brief Instead of calling the `open()` function from the Menu control, you should invoke this function. This will take care of positioning the ContextualMenu popup in the right manner.
73 * @param x The x coordinate where to show the menu popup. This is ignored if the menu is `responsive`.
74 * @param y The y coordinate where to show the menu popup. This is ignored if the menu is `responsive`.
75 * @param parent The parent item from where the coordinates are based on to popup the menu.
76 */
77 function show(x, y, parent)
78 {
79 if (control.responsive)
80 {
81 control.open()
82 }
83 else
84 {
85 control.popup(parent,x ,y)
86 }
87 }
88}
89
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:56:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.