Is there a way to enable user to see a drop down menu when he/she right clicks to the map? And when he selects one of the items in that menu, some action needs to be performed.
Hello again @FatmaAkdemir ,
In that case you can use "mousePressed" with "RightButton" to catch the mouse events and "QMenu::exec" to open a context menu. Or if you don't want to use a menu, you could use "QPushButton" instead.
Documentation for C++:
https://developers.arcgis.com/qt/cpp/api-reference/esri-arcgisruntime-mapgraphicsview.html
https://doc.qt.io/qt-5/qmenu.html#exec-1
https://doc.qt.io/qt-5/qpushbutton.html
Sincerely,
Jared
Hello @FatmaAkdemir,
Yes using a combination of the MapView and QtQuick.Controls you definitely could. You would need to listen for the MapView.onMouseClicked signal and then use mouse.x and mouse.y then use those to update the x and y of the QtQuick.Controls ComboBox(drop down menu) which can take a ListModel(list of items in that menu) then you can listen for the ComboBox.onActivated(int index) signal for the selection from that list and use the index to know which model from that list was selected and do whatever following action you would like.
Here is an example:
import QtQuick 2.6 import QtQuick.Controls 2.2 import QtQuick.Dialogs 1.2 import Esri.ArcGISRuntime 100.11 ApplicationWindow { id: appWindow width: 800 height: 600 title: "Example" property var myExModel : ["apple", "pie", "cherry", "pie"] // add a mapView component MapView { anchors.fill: parent // set focus to enable keyboard navigation focus: true // add a map to the mapview Map { // add the ArcGISStreets basemap to the map initBasemapStyle: Enums.BasemapStyleArcGISStreets } onMouseClicked: { myComboBox.x = mouse.x; myComboBox.y = mouse.y; myComboBox.visible = true; } } ComboBox { id: myComboBox model: myExModel visible: false onActivated: { myDialog.text = myExModel[index]; visible = false; myDialog.open(); } } MessageDialog { id: myDialog } }
Hope you find this helpful!
Hi @JaredCaccamo ,
Thank you for the detailed answer. Unfortunately I am not using QML. Should I use QComboBox in this case? In fact I only need a pop-up button ("Delete") when user right clicks on a graphic. After user clicks on that button, graphic will be deleted from the map.
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.