Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Disable Context menu

This is a discussion on Disable Context menu within the MapPoint Desktop Discussion forums, part of the Map Forums category; Ive had this problem for a few days now, and I am all out of ideas. I am using the ...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    Disable Context menu

    Ive had this problem for a few days now, and I am all out of ideas. I am using the selection change event to display custom context menus depending on which pushpin the user rightclicks on. However, the default context menu pops up after my menu. Initially I though i could just use "cancel" in the before_click event, but if i cancel that event, then no selection_change event occurs and I get no menu at all.

    I have gotten around this before by displaying my menu from the before_click function. That worked fine when there was only one context menu. But now I need to have a different menu for each pushpin set. I dont know of anyway to do that from the before_click event which is why i moved the code to the selection_change event.

    I am using c# by the way.

    Any help or ideas would be greatly appriciated.

    Thanks

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    Initially I though i could just use "cancel" in the before_click event, but if i cancel that event, then no selection_change event occurs and I get no menu at all.
    What if you use cancel only if right button is clicked ? I think you have that option to check in BeforeClick. I'm sure other solutions are possible but this is what drop into my head at first glance.

  3. #3
    GxW34 is offline Junior Member White Belt
    Join Date
    Apr 2005
    Posts
    5
    Thanx for your reply. Canceling only on right clicks is what I was referring to. But that means that right clicks can no longer trigger selection change events, so my menus wont work when someone right clicks on an icon.

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    I understeand. I was thinking that the e.cancel only canceled the popup menu, but of course it cancel the action, whatever it is. Since you definily need both of the events maybe the workaround is to get rid of the popup menu by sending escape key to it. Then you can go along and still think on a better solution.

  5. #5
    GxW34 is offline Junior Member White Belt
    Join Date
    Apr 2005
    Posts
    5
    Hi, it's been a little while since I originally posted this question. I used the esc key workaround suggested by Wilfried and it allowed me to continue on with other things. However, now I am back at the context menu problem again, and I still have not though of a good way of solving it. I am beginning to think that maye I cant disable the context menus without also disabling selection_change event. In which case, I need to come up with another way of determining which pushpin was clicked on so that I know which menu to pop up.

    So if anyone has any ideas on how to disable the menus without canceling the selction change event, or a way to determing which pushpin is being clicked without having to use the selection change event, I would greatly appriciate it.

    Thanks for your help

  6. #6
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    Sometime (often) time brings the light

    I cannot test this, but there are some things you can use. There is a property ActiveMap.Selection, witch gives you the selected object if any. So what you can do is send the escape key to get rid of the popup menu, but first you get the selected object of course.

    After you send the escape you Select() the selected object again.

    Does that sounds pretty ?

    Ok this is from top of my head, but I think it should work, if not it can give additional toughts. it is also possible that you have to delay a timeslice to select again, but only a little experiment will see if it is the case.

    What do you think ?

  7. #7
    GxW34 is offline Junior Member White Belt
    Join Date
    Apr 2005
    Posts
    5
    Thanks, that is a very good idea. I tried something very similar to that also. The problem I ran into was that if I get the selected item in the before click event, I am getting the item that they selected last time, not the one they are trying to select right now. I cant get the item they are selected right now ( or at least I dont know how to get it) until after the selection change event has occured, and by then it is too late. All I can do then is send and ESC key after my menu pops to cancel the other menu. This does get the job done, but it does not look good (sometimes you can still see the mappoint menu for a split second) and it is not completely reliable. (sometimes my menu gets the ESC and the mappoint menu pops up).

    I do really appriciate your help, and I have thought of few other things to try, but if you have any more ideas I would be more than happy to hear them.

    Thanks again
    GxW34

  8. #8
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    Hmm of course, in BeforeClick it is not yet clicked so not yet selected. I have no idea's right now. If I come up with something I will reply again here, maybe some others have some inspiration ?

    Yes sometimes you will see the mappoint menu for a small time with this approatch. I think you canonly call this a minor flaw and nothing to do unless you find another approach.

    It should be reliable, but then you have to do it as this:
    1 send the escape key
    2 post a message to custom message handler
    3 let the custom message handler create your menu

    Windows messages events are always processed in right sequence so by doing it so, the escape key is send long before your menu is created.

  9. #9
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    I have another idea. In BeforeClick if you set e.cancel = true then there is no selection eather. but you know there the x and y coordinates of the mouse. So there you can do something like:

    Code:
                FindResults results = MP.ActiveMap.ObjectsFromPoint(e.x, e.y);
                foreach (object o in results) {
                    Pushpin pp = o as Pushpin;
                    if (pp != null)
                        pp.Select();
                }
    This handles of course only pushpins. I dont know if there is a method in mappoint to select() any objec if it is selectable. But if this works I think you are in a better direction, right ?

  10. #10
    GxW34 is offline Junior Member White Belt
    Join Date
    Apr 2005
    Posts
    5
    Hi Wilfried,

    I just wanted to tell you that your idea worked perfectly!! I knew the ObjectsFromPoint function existed, but I probably never would have thought of using it in this situation. Thanks for your help, I really appreciate it.

    GxW34

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Click events of context menu are not firing....
    By Learner in forum MapPoint Desktop Discussion
    Replies: 6
    Last Post: 05-12-2008, 03:33 PM
  2. By Right-click displaying context menu on map
    By Banu in forum MapPoint Desktop Discussion
    Replies: 19
    Last Post: 10-16-2007, 08:46 AM
  3. Custom context menu
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 09-10-2004, 11:15 PM
  4. Extending MapPoint - How about the Context Menu Enhancements
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 02-10-2004, 10:38 AM
  5. VB.NET & overriding the map point context menu...
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 09-05-2002, 09:25 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96