Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Context Menu for Timeline Events

    Hi Isomorphic

    I'm trying to add a context menu that appears when you right-click on an event in a Timeline.

    I've tried overriding the getEventCanvasMenuItems method to return an array of MenuItems but this is not working as expected. I also don't see a context button when rolling over the event as mentioned in the Javadoc. Is there something else required?

    Here's what I have so far:

    Code:
     public void onModuleLoad() {
            Timeline timeline = new Timeline() {
                @Override
                public MenuItem[] getEventCanvasMenuItems(EventCanvas canvas) {
                    return new MenuItem[] { new MenuItem("Item 1"), new MenuItem("Item 2") };
                }
            };
            timeline.setWidth100();
            timeline.setHeight100();
            timeline.setStartDate(new Date(122, 10, 25));
            timeline.setEndDate(new Date(122, 10, 30));
            timeline.setShowEventDescriptions(false);
            timeline.setShowEventHeaders(false);
            timeline.setCanEditEvents(Boolean.FALSE);
            timeline.setShowControlsBar(Boolean.FALSE);
            timeline.setLanes(new Lane("lane1", "Lane 1"));
            timeline.setData(new CalendarEvent(1, null, null, new Date(122, 10, 26), new Date(122, 10, 27), "lane1"));
    
            timeline.draw();
        }
    I'm using the following:

    SmartClient Version: v12.1p_2022-11-23/Pro Deployment (built 2022-11-23)
    GWT 2.9.0
    Chrome 107.0.5304.107 (Official Build) (64-bit)

    Thanks
    Last edited by stonebranch3; 25 Nov 2022, 14:18. Reason: Fixed year parameters.

    #2
    Good question - as an immediate fix, you can get the contextButton to show up on all event canvases by setting showContextButton to true via a call to EventCanvas.setDefaultProperties(). That should get your sample code working.

    Longer term, there's an undocumented internal customizeCanvas() which we could look at exposing, although it may not port to SGWT very well as-is - we'll talk about it internally and get back to you.

    Comment


      #3
      I'm not seeing a showContextButton/setShowContextButton method for the EventCanvas.

      Comment


        #4
        Ah, it isn't public - you could do it with JSNI for now, $wnd.isc.EventCanvas.addProperties({ showContextButton: true }) - we'll expose that attribute to SGWT, and perhaps look at adding an easier API.

        Comment


          #5
          Unfortunately, that doesn't seems to work either. I tried adding the showEdges property and that worked so the JSNI is correct.

          Comment


            #6
            It looks like getEventCanvasMenuItems() isn't a true override point in SGWT - we'll add a customizer for it and expose EventCanvas.showContextButton this weekend.

            Comment


              #7
              We've made a change to address this issue. As of today's builds, dated November 28 or later, you can install getEventCanvasMenuItems() via new Calendar.setEventCanvasMenuCustomizer(), rather than by directly overriding getEventCanvasMenuItems(), and things should work as you expect without any other changes.

              Please let us know if you still see any issues.

              Comment


                #8
                The context menu is now working when right-clicking on an event using the November 28 build. I still don't see the showContextButton method on the EventCanvas but I was able to get the context button to show up using JSNI.

                Thanks!

                Comment


                  #9
                  We've exposed EventCanvas.showContextButton for today's builds, if you want to replace the JSNI - we may go ahead and add a more direct/accessible attribute or method on Calendar to enable this button and we'll update here if we do.

                  Comment


                    #10
                    I have confirmed that the method is visible with today's build and working as expected. Thanks!

                    Comment

                    Working...
                    X