[Laszlo-dev] For Review: Change 20090516-bargull-GQn Summary: once more contextmenus for dhtml
André Bargull
andre.bargull at udo.edu
Sat May 16 16:35:27 PDT 2009
On 5/16/2009 9:34 PM, Max Carlson wrote:
> Very nice, but it still needs some work. From LzMouseKernel:
>
> document.oncontextmenu = ison ? LzMouseKernel.__contextmenuEvent : null;
>
> In order to prevent the default context menu from showing when clicking
> on the canvas, __contextmenuEvent() must return false:
>
> ,__contextmenuEvent: function (e) {
> var showncm = LzMouseKernel.__showncontextmenu;
> if (showncm) {
> return showncm.showbuiltins;
> }
> }
>
> This only happens when LzMouseKernel.__showncontextmenu has a value -
> it's reset whenever the context menu is hidden. Therefore, after the
> menu is hidden, a right-click causes both the browser and custom context
> menu to show up.
A right-click fires first an onmouseup-event (with button=2 -> this
shows the custom contextmenu) and then an oncontextmenu-event. So it
shouldn't be possible that the contextmenu is hidden for oncontextmenu.
(I've just found out that right clicking on the custom contextmenu shows
the browser contextmenu, this needs to be fixed.)
>
> The fix is simple:
> __showContextMenu() must return the value of cmenu.showbuiltins when
> available:
> if (cmenu) {
> cmenu.kernel.__show();
> return cmenu.kernel.showbuiltins;
> }
>
> __showContextMenu() should be used for oncontextmenu events:
> document.oncontextmenu = ison ? LzMouseKernel.__showContextMenu
> : null;
But this will reintroduce the issue with double onmenuopen-events..!?
>
> __contextmenuEvent() can be eliminated because it's no longer used.
>
> Here's a patch for your version of LzMouseKernel:
> 49,54d48
> < ,__contextmenuEvent: function (e) {
> < var showncm = LzMouseKernel.__showncontextmenu;
> < if (showncm) {
> < return showncm.showbuiltins;
> < }
> < }
> 113c107
> < document.oncontextmenu = ison ?
> LzMouseKernel.__contextmenuEvent : null;
> ---
> > document.oncontextmenu = ison ?
> LzMouseKernel.__showContextMenu : null;
> 298a293
> > return cmenu.kernel.showbuiltins;
>
> Otherwise, approved!
>
> André Bargull wrote:
>> Change 20090516-bargull-GQn by bargull at dell--p4--2-53 on 2009-05-16
>> 17:15:31
>> in /home/Admin/src/svn/openlaszlo/trunk
>> for http://svn.openlaszlo.org/openlaszlo/trunk
>>
>> Summary: once more contextmenus for dhtml
>>
>> New Features:
>>
>> Bugs Fixed: LPP-8189 (Right click fires an erroneous mousedown and
>> mouseup in DHTML.), LPP-8142 (On a mac right click using two finger
>> tap on the trackpad doesn't register as right click, it registers as
>> left click)
>>
>> Technical Reviewer: max
>> QA Reviewer: henry
>> Doc Reviewer: (pending)
>>
>> Documentation:
>>
>> Release Notes:
>>
>> Details:
>> LzContextMenuKernel:
>> - remove "__sentshowevent", it didn't work properly (consider this:
>> right to open contextmenu, then right click again => __sentshowevent
>> is still set => no onmenuopen event)
>> - remove listeners to onmousedown, onmouseup, onclick from
>> anchor-elements, this didn't work in Firefox. Instead add handlers to
>> lzcontextmenu-div
>> - only show contextmenu if "showbuiltins" isn't set
>> - remove ignore-arg from __hide(), no longer needed
>>
>> LzSprite:
>> - add quirk for Safari, because middle mouse button click sends
>> onclick-event
>> - canceling event-bubbling for all mouse-events => this was already
>> done for all browsers (except Firefox) and all events (except
>> onmouseup). Why wasn't Firefox affected? => All other browsers set
>> "event.keyCode" to '0' for mouse-events, only Firefox sets "keyCode"
>> to 'undefined'. Now take a look at
>> "LzKeyboardKernel.__keyboardEvent()", every event was canceled in that
>> function if "keyCode" was '>= 0'!
>> - only handle onmousedown/onmouseup for left button
>> - if right button is clicked, delegate onmouseup event to
>> LzMouseKernel to show contextmenu
>>
>> LzKeyboardKernel:
>> - move handling for control keys (ctrl, shift, alt) into separate
>> function. It should be obvious why having a single function for both,
>> mouse-events and keyboard-events, is a bad idea (see keyCode issue
>> from above).
>>
>> LzMouseKernel:
>> - hide contextmenu on "onmousedown", not "onclick". Because it's
>> compliant with swf and if you drag the mouse, you don't get an
>> "onclick"-event, so drag and click won't hide the contextmenu
>> - again, only onmousedown/onmouseup for left button
>> - and show contextmenu if right button is clicked
>>
>>
>> Tests:
>> see tests from bugreports (IE, Firefox, Safari, Opera)
>>
>> Files:
>> M WEB-INF/lps/lfc/kernel/dhtml/LzKeyboardKernel.js
>> M WEB-INF/lps/lfc/kernel/dhtml/LzContextMenuKernel.lzs
>> M WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
>> M WEB-INF/lps/lfc/kernel/dhtml/LzMouseKernel.js
>>
>> Changeset:
>> http://svn.openlaszlo.org/openlaszlo/patches/20090516-bargull-GQn.tar
>>
>
More information about the Laszlo-dev
mailing list