Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Toolbar button events - oncommand and ondblclick

1 view
Skip to first unread message

Tom

unread,
Jan 3, 2010, 3:49:28 PM1/3/10
to
Hi All,

I have a toolbar that has a couple buttons that must handle the click and
double click events differently. In other words the command handling logic
is different for a click event and double click event. The problem is that
when I do a double click I still get the single click event. I have tried
impleming the setTimeout function but that does not work at all. Does
anybody have a idea on how to handle these two events and not both at the
same time.

I have been playing around with the following in each event handler

// Click event
globaldoubleClick=false;
window.setTimeout(function(){doSomething();}, 300);
if(globaldoubleClick)
return;
HandleSingleClickLogic();

//Dblclick
globaldoubleClick=true;


Thanks,
Tom


Neil

unread,
Jan 4, 2010, 4:48:59 AM1/4/10
to
Tom wrote:

>// Click event
>globaldoubleClick=false;
>window.setTimeout(function(){doSomething();}, 300);
>if(globaldoubleClick)
> return;
>HandleSingleClickLogic();
>
>//Dblclick
>globaldoubleClick=true;
>
>

Your code does almost implement one way of working around your problem,
but you need a couple of tweaks:

function onClick() {
globaldoubleClick = false;
window.setTimeout(function(){doSomething();}, 300);
}
function doSomething() { // XXX need to rename this
if (globaldoubleClick)
return;
HandleSingleClickLogic();
}
function onDoubleClick() {
globaldoubleClick = true;
HandleDoubleClickLogic();
}

--
Warning: May contain traces of nuts.

Vikram Baghel

unread,
Jan 4, 2010, 7:35:23 AM1/4/10
to
=====================
Tom... why don't you make use of <popupset> and having the context
value assigned. Your XUL file will look something like this..


<popupset id="mainPopupSet">
<!-- Right-click menu for toolbar item -->
<popup id="Button_context_menu">
<menuitem id="someIDagain"
label="Label"
oncommand="RightClickFunction();" />
</popup>
</popupset>


<toolbarpalette id="someID">
<toolbarbutton id="something"
label="Button"
class="toolbarbutton-1"
context="Button_context_menu"
oncommand="LeftClickFuction();" />
</toolbarpalette>


Tom

unread,
Jan 5, 2010, 9:36:34 AM1/5/10
to
Thanks Neil,

I figured it out.

"Neil" <ne...@parkwaycc.co.uk> wrote in message
news:l4qdnQ6u1YEWJNzW...@mozilla.org...

0 new messages