Fork me on GitHub
#hoplon
<
2017-10-26
>
chromalchemy22:10:21

In Chrome on Win 8 touchscreen, If I do a long touch, the browser's contextual menu pops up. I would like to suppress the default context menu, so I can can use touch events more reliably. And hopefully implement my own contextual menus and long-press options. How would I go about this? I am using Hoplon UI, which has a (window) function for the main view, instead of (body)... but I'm assuming this would not prohibit me from modifying this behavior.

chromalchemy22:10:59

I have this so far

(.addEventListener js/window "contextmenu"
    (fn [e] (.-preventDefault js/window)))
But no luck yet. And where would I put it?

chromalchemy22:10:52

Hoplon UI provides attributes for "auxclick" and "contextmenu" events. But I dont know how to go about suppressing the default browser menu.

chromalchemy22:10:57

Is there a way to add this behavior ad hoc, without modifying the UI library?

chromalchemy22:10:30

Got it! :ctx-menu #(.preventDefault %) in attrs works. I can apply this to (window) for a global reset. Then override on elems as needed. Nice and simple. Hoplon is awesome!!! I can do so much with about zero javascript experience.