Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #109681
    Ondřej
    Participant

    Hello,

    is possible to make dynamic context menu based on if user click on empty cell or event?

    When I tried it during onContextMenuOpening, it was present during second click

    Thank you very much

    #109684
    Markov
    Keymaster

    Hi,

    You can use the contextMenuOpening event to prevent the default context menu. In the event.detail, depending on whether you clicked a cell or event, you will have either cellObj or eventObj. By calling event.preventDefault() you will prevent the default context menu and you can open a custom context menu.

    Best regards,
    Peter Stoev

    Smart UI Team
    https://www.htmlelements.com/

    #109784
    Ondřej
    Participant

    Hello,

    is possible to get mouse position in onContextMenuOpening to position custom context menu?

    Event is CustomEvent without original event object (or I didn’t know where to find it)

    Thank you very much

    #109786
    ivanpeevski
    Participant

    Hi,

     

    One way to achieve this is by using the “mousemove” event to keep track of the mouse:

    let mouseX, mouseY;
    document.querySelector(‘smart-scheduler’).addEventListener(‘contextMenuOpening’, function(event){
    event.preventDefault();
    console.log(mouseX, mouseY)
    })

    document.querySelector(‘smart-scheduler’).addEventListener(‘mousemove’, function(event){
    mouseX = event.pageX;
    mouseY = event.pageY
    })

     

    Best regards,
    Ivan Peevski

    Smart UI Team
    https://www.htmlelements.com/

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.