Possible to hook into mapper rightclick menu?

All and any discussion and development of the Mudlet Mapper.
User avatar
chris
Posts: 493
Joined: Fri Jun 17, 2011 5:39 am

Re: Possible to hook into mapper rightclick menu?

Post by chris »

You need to set it up for variable # of arguments, which is '...'. If you look in my function example you can see how the function needs to be setup. I'll be releasing an update shortly which is going to add menus as well (I want to have a color dropdown so I'm adding this)

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Possible to hook into mapper rightclick menu?

Post by Vadi »

Use:
Code: [show] | [select all] lua
function test(event, ...)
  local list = {...}
  echo("\nmyTestEvent\n")
  display(list)
end

User avatar
chris
Posts: 493
Joined: Fri Jun 17, 2011 5:39 am

Re: Possible to hook into mapper rightclick menu?

Post by chris »

I added a bunch of new features to this, check my github repo post for details.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Possible to hook into mapper rightclick menu?

Post by Vadi »

removeMapMenu("") made a crash:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff64ea562 in QWidget::insertAction(QAction*, QAction*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
(gdb) bt
#0 0x00007ffff64ea562 in QWidget::insertAction(QAction*, QAction*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#1 0x00007ffff68d4d27 in QMenu::addMenu(QMenu*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#2 0x0000000000614d5a in T2DMap::mouseReleaseEvent (this=0x43bbe50, event=0x7fffffffcd70) at T2DMap.cpp:1582
#3 0x00007ffff64f1c9a in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#4 0x00007ffff64a1424 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#5 0x00007ffff64a6c6b in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Possible to hook into mapper rightclick menu?

Post by Vadi »

It seems that both getMapEvents and getMapMenus aren't returning anything, when they should be.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Possible to hook into mapper rightclick menu?

Post by Vadi »

I documented the current API in the original post of this thread.

InTheWorks
Posts: 18
Joined: Sat Sep 10, 2011 7:37 am

Re: Possible to hook into mapper rightclick menu?

Post by InTheWorks »

had a chance to play with the changes and here's some feedback.

addMapEvent("Merge this room", "mergeThisRoomEvent", "Merge")
addMapEvent("Merge into this room", "mergeIntoThisRoomEvent", "Merge")
addMapEvent("Cancel", "mergeCancelEvent", "Merge")

gives the order:

Cancel
Merge into this room
Merge this room

while:
addMapEvent("Cancel", "mergeCancelEvent", "Merge")
addMapEvent("Merge into this room", "mergeIntoThisRoomEvent", "Merge")
addMapEvent("Merge this room", "mergeThisRoomEvent", "Merge")

also gives the order:

Cancel
Merge into this room
Merge this room

Obviously I'd like to be able to place Cancel at the bottom, somehow....

and,
lua addMapEvent("Cancel", "mergeCancelEvent", "Merge")
lua addMapEvent("Cancel", "otherCancelEvent", "SomeOtherMenu")

simply moves Cancel from Merge to SomeOtherMenu. I can certainly see having multiple menus with a Cancel. So it would be good to specify "Merge/Cancel" to removeMapEvent, or find some other way to delineate sub menus.

also
addMapMenu("test")
addMapMenu("testing", "test")
addMapEvent("My Test Event", "myTestEvent", "testing")
removeMapMenu("test")

causes a seg fault when the right click menu is shown.

but otherwise, it does as advertised and I am able to work the menu for my merge script.

InTheWorks
Posts: 18
Joined: Sat Sep 10, 2011 7:37 am

Re: Possible to hook into mapper rightclick menu?

Post by InTheWorks »

InTheWorks wrote:As the title says, is it possible to get notification in my mapping script when a user changes the location using the right click menu "Set Location Here". Is there an event mechanism?
Was this addressed and I missed it? If not, is it too much trouble to add?

User avatar
Omit
Posts: 190
Joined: Sun Aug 01, 2010 10:54 pm
Location: Middle Earth
Contact:

Re: Possible to hook into mapper rightclick menu?

Post by Omit »

I like that idea a lot. It would be a lot more effencient than checking what your location is before doing anything in a mapping script. (and that is what you need to do in order to let a user 'set Location Here').

User avatar
chris
Posts: 493
Joined: Fri Jun 17, 2011 5:39 am

Re: Possible to hook into mapper rightclick menu?

Post by chris »

For the get/remove routines, I barely tested them, I intended to test them out so I added them to the headers so I only had to eat the compile time once. Basically this is one of those instances you code, it compiles, and you assume they work. For the order, the structure for the actions/labels is a map dictionary, which has a 1:1 mapping. This is why the menu items are being moved. The displayName is unique. Additionally, since it's a QMap they are stored alphabetically. I can maybe look into other structures, but in general I think having duplicate display names might be a bad idea from purely the user stance (though yes, the submenu aspect does assist in guiding the user). May it can be a recursive QMap for each element, I'll look into it. For the 'cancel' action, why on earth would you need that in a right click menu? You either do something or you don't. There shouldn't be the need to cancel anything.

Post Reply