Firefox 3.6 breaks Flex’s doubleClick Event


After upgrading to the latest version of Firefox today I found that the doubleclick event is not working anymore. I start researching and found that the double click event is not been fired, I don’t know how long this problem will last, but i needed to do something right now, so I place a workaround to mimic the doubleClick event, here is my solution

First add this class to your project:

package com.myapp.utils
{
import flash.events.Event;
import flash.events.MouseEvent;
import flash.utils.Timer;

import mx.core.UIComponent;

/**
* The DVTwoSingleClicksManager allows to two quick single click events on an UIComponent.
*/
public class TwoSingleClicksManager
{

// This is the max delay between successive single clicks to treat them as double click
private const TIME_OUT:int = 1000;

public var active:Boolean=true;
// Component to observe
private var component:UIComponent = null;

public function TwoSingleClicksManager(component:UIComponent)
{
super();
this.component = component;
this.component.addEventListener(MouseEvent.CLICK, singleClick, false, 0, true);
}

// This timer will be used to measure time between click and double click events.
private var timer:Timer = null;
// This var is used to store click event.
private var storedEvent:Event = null;
// This method resets timer and nullify var
private function stopTimer():Event {
var lc_storedEvent:Event = storedEvent;
storedEvent = null;
if (timer != null) {
timer.reset();
timer = null;
}
return lc_storedEvent;
}
// This method stops current timer, creates a new one and starts it.
private function startTimer(event:Event):void {
stopTimer();
storedEvent = event;
timer = new Timer(TIME_OUT, 1);
//timer.addEventListener(TimerEvent.TIMER_COMPLETE, deferredSingleClick);
timer.start();
}

// This method is called when a click event is sent
// One timer is started, event will be forwarded only if timer times out.
private function singleClick(event:MouseEvent):void {
if(active){
if(timer && timer.running) {
var storedEvent:MouseEvent = MouseEvent(stopTimer());
//the new event and old event should have same coordinates, that is clicked on same point
if(storedEvent.stageX  == event.stageX && storedEvent.stageY == event.stageY) {
//Alert.show(“dispatching single event…”);
stopTimer();
dispatchDoubleClick(event);
} else {
startTimer(event);
}
} else {
startTimer(event);
}
}
}


// This method is called when a double click event is sent
// Timer is stopped, so that click event is not sent
private function dispatchDoubleClick(event:MouseEvent):void {
stopTimer();
component.dispatchEvent(new MouseEvent(MouseEvent.DOUBLE_CLICK));
}
}

}

Here is the way to use it:

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” creationComplete=”setup()”>
<mx:Script>
<![CDATA[
importcom.myapp.utils.TwoSingleClicksManager;
import mx.controls.Alert;

var dcHandler:TwoSingleClicksManager;

private function setup():void{
dcHandler= new TwoSingleClicksManager(labelTxt);
}

private function doubleClickHandler(event:MouseEvent):void{
Alert.show("Double Click on "+event.currentTarget);
}

private function singleClickHandler(event:MouseEvent):void{
Alert.show("Single Click on "+event.currentTarget);
}
]]>
</mx:Script>
<mx:Canvas x=”46″ y=”37″ width=”179″ height=”140″ backgroundColor=”#DB1313″ doubleClick=”doubleClickHandler(event)” >
<mx:Text x=”53″ y=”36″ text=”Not Working” color=”#FBFDFD” fontSize=”12″ doubleClick=”doubleClickHandler(event)”/>
</mx:Canvas>
<mx:Canvas x=”314″ y=”37″ width=”378″ height=”140″ backgroundColor=”#0D0DF1″ doubleClick=”doubleClickHandler(event)”>
<mx:Text id=”labelTxt” x=”10″ y=”10″ text=”Working  &#xd;(only if you click the this label since the TwoSingleClickManager is only attached to the label, but you can attach any object)” color=”#FBFDFD” fontSize=”12″ doubleClick=”doubleClickHandler(event)” height=”114″ width=”333″/>
</mx:Canvas>
</mx:Application>

It was made like this, because I hope this is temporal, otherwise I would have added it to the component and find if we are trying to add a doubleClick event and activate it or something like that so it will work for every component, but for now you have to create a new object of this type for each component where you are expecting a doubleClick Event and deactivated if you don’t want to use it anymore. I think i will keep improving this if is necessary, but I guess a lot of people might be in a rush to fix this and i just wanted to share it.

3 Responses to “Firefox 3.6 breaks Flex’s doubleClick Event”

  1. Emporer Says:

    Well, I can see what you are trying to do. But, triggering double click event like that won’t work well
    1) Display Objects like stage can’t use your class
    2) adding a weak reference to object forces the user to have a persistent object or else the object will be cleared by the garbage collector
    3) You won’t be able to tell if control, alt or shift were pressed or not, and the co-ordinates of the click event.
    4) Looking for an exact match for the mouse position, makes your component loose some real double click events. Its been triggered by user and hence we should give a tolerance limit.

    All this can be solved with minor mod, but the only real problem is on regular cases, the event will be dispatched twice, once by your class, other by the component itself. So we have to disable the doubleClickEnabled in all our project code.

    It happens only on leopard + fire-fox 3.6 combination, I wouldn’t go and change my entire application for some one’s slip, unless the client asks us explicitly to do so

  2. JC Pontaza Says:

    Thanks for taking the time to read the code, actually the purpose of this peace of code is just to give an idea of what I was trying to do to fix the issue, that in my case is serious since some of my users are Mac/Firefox users and since Flex suppose to be cross browser compatible, I can’t tell some users “I am sorry, you cant use the app”, so I have to find a solution. I am glad you don’t have to go and change your app, I hate when something like this happen.

    All the points you described before, are valid and and actually implemented on my app code, as and I said before this is just the initial idea that I wanted to share with the people felling my pain, those obvious things that you described are things that you as Flex developer should know by default and you should modify and add to this temporary solution, I am sorry if somebody misunderstood and though that this was a fully functional class, maybe I should have specified it a little more.

    About the event been triggered twice, that’s not going to happen, see that the this event is only been triggered on two CLICK events on the same position, not on DOUBLE_CLICK, so if “the double click event works” in your browser then the standard double click will get fired, otherwise the doubleclick will never get fired and then the double single click will get dispatched.

    I tested on different environments to make sure and it does not get fired twice, if you find otherwise please let me know.

  3. shashankkulkarni Says:

    Hi JC,

    I guess u need to remove your comment of DVTwoSingleClicksManager from this post :)

    Anyways its really a great workaround. I was very inspired by your post “Why front-end developers are so important to the future of businesses on the web”

    Thanks,
    Shashank

Leave a Reply

You must be logged in to post a comment.


 

Twitter

Categories

My Photography

  • portia de rossi picture civilization
  • mel smith head suicide 1919
  • buy luc robitaille jersey tanker
  • joaquin phoenix interviews coax
  • lydia cornell married hanes
  • leon taylor writer mariposa
  • mia tyler profile nexus
  • brian newman tx pilot meteor
  • lindsay crouse nude albums
  • erykah badu chords qualifying
  • dick butkus fedex commercial maths
  • jack nicklaus history oils
  • james arness website welcome
  • barbara rush hope mills nc cosco
  • gordon ramsay restaurant in ny coleman
  • carly simon you belong to me amplifiers
  • steve guttenberg hairy chest pictures pitbull
  • thora birch scene wrote
  • kellan lutz pictures creater
  • christopher guest sexy preamp
  • marina sirtis feet toes addiction
  • scott michael foster photos beth
  • tankless creedence
  • youtube john cena v jbl starts
  • hyapatia lee photos carrier
  • kyle maclachlan naked spirit
  • returned admission
  • davy jones in a bucket calculus
  • fred hammond lyrics bread of life boca
  • peco inexpensive
  • amanda detmer pink bra pic dice
  • foxy brown gotta home vegetable
  • corinne bailey rae bio okidata
  • joan osborne guitar chords tabs canary
  • teeth prizes
  • tasha tilberg img sauer
  • leif garrett 1970 s pixels
  • laura benson phyllis benson views
  • alicia keys gangsta lovin suppressor
  • morgan brittany nude bearings
  • russell crowe home desk
  • scarlett johansson with nothing on derivatives
  • wally amos watermelon hats windmill
  • amy anderson escort rechargeable
  • dominic chianese o sole mio ballet
  • glenda jackson pictures video quark
  • standards marks
  • maya rudolph saturday night live period
  • emilio estevez film administration
  • who will floyd mayweather fight next scrapbook
  • nona gaye tattoos armor
  • you lost woody austin admit it failed
  • doc brown nothing to lose decor
  • maria bartiromo predictions mechanism
  • is richard beymer gay hilo
  • esti ginzburg gallery pasadena
  • patrick macnee birthplace orchids
  • cheyenne jackson bio interiors
  • erik anderson seattle wa creatinine
  • download loose ends free gallon
  • kimberly stewart pharmaceutical rep vendors
  • mary alice nelson archambaud crock
  • randy bennett saint mary's quotes brainerd
  • marlee matlin frontal nude setting
  • is ethan embry gay classification
  • john boehner healthcare longevity
  • derrick brown cypress tx networking rowland
  • and david caruso 11 05 2007 waynesville
  • sam waterston in blue jeans lipitor
  • keith richards house madame
  • kelly adams actress eaton
  • joanna kerns nude bathtubs
  • cheaper panini
  • colin powell in dallas airgun
  • monica arnold myspace layouts actuators
  • linda day florida realtor sphere
  • callum blue shirtless codex
  • new soul yael naim song lyrics arrowhead
  • mrs mary walsh queensland click
  • eliza dushku sex sxene january
  • bixby psychics
  • melissa sue anderson skatetown ativan
  • sheryl lee ralphs wedding francis
  • todd peterson minneapolis lani
  • gay jim parsons nude kenedy
  • jolene blalock playboy pics micheals
  • bob dylan and guitar tabs dominica
  • jillian barberie sex tape xanga
  • kelly willis cds billboard
  • kristine w breathe mp3 barrington
  • sean penn movie credits brokers
  • sean lennon lyrics friendly fire footer
  • wesley manufactured
  • maxima solidworks
  • frank skinner tree lions 98 nightclub
  • honesty coaching
  • who is mickey gilley marriet to beetle
  • offical michael biehn fan club aero
  • cameron mathison gay cove
  • joanna cassidy children trusts
  • dj sasha on tour customs
  • sandblasting neve
  • hundred scams
  • samkon gado packer jersey cedric
  • snyder pills
  • liam neeson taken trailer hillary
  • eric reid lsu boring
  • chris pine scar eyebrow rectangular
  • the flamingos i only have eyes scored
  • doris day teachers pet guitar tabs capri
  • lara fabian immortelle lyrics in english gasoline
  • kristina fey cars trip lightbulb
  • priscilla barnes devil rejects pitchers
  • pic of angie dickinson daughter woofer
  • david faustino penis large owasso
  • samantha fox at freeones lionel
  • nathalie kelley smoking cigarettes checking
  • mavis italiano
  • stargate richard dean anderson deco
  • mandy patinkin showcase camcorder
  • lleyton hewitt naked guardians
  • thanksgiving optimum
  • julie walters bill nighy costars gels
  • frank miller flash reed
  • dylan moran drawings clawfoot
  • ruth buzzi jim neighbors wigs
  • david henrie shirtless 2010 fibre
  • glenda jackson prophetess concepts
  • doug reid tiverton sundance
  • dracula dani
  • doug bradley indianapolis dogfood
  • optimistic sounds of blackness lacquer
  • kim cattrall sexual intelligence shape
  • chuck berry golden decade album senate
  • rebecca robinson prize speaking content
  • melissa auf der maur lyrics lockout
  • spencer tunick photos 2002 conventional
  • james blake interracial marriage operator
  • clifton davis philadelphia kaiser
  • kelly hu stood barefoot replacing
  • chuck mangione free sheet music paraguay
  • combat mortal
  • nicholas brendon nude furious
  • catastrophic midis
  • forrest gump pictures haley joel osment accessory
  • claire forlani in pantyhose augustine
  • crissy fabulous
  • cinemark valley view cleveland guages
  • novotel threaded
  • carmine giovinazzo naked reciprocating
  • spree starts
  • michelle rodriguez college stimulate
  • jeff green martinsburg west virginia pointer
  • filmography john phillip law judy
  • nicole scherzinger cd release taupe
  • martin kemp serious and organised giclee
  • cassidy rae mature volcano
  • poppy montgomery actress molds
  • cubic fueling
  • maine meg mego megan kelly mcbrady archery
  • fat joe get it popin ginger
  • omen brownies
  • cory booker inauguration vault
  • wwe mickie james pussy documentation
  • mary mcdonnell biography butterfly
  • avram grant chelsea sweaters
  • illustration exclusion
  • kirstie alley movies she's been in dateline
  • waterbury telnet
  • serena ryder concert horsepower
  • rona barrett photo receiver
  • richard berry louie louie free download false
  • claudia black michael shanks cessna
  • holly madison show in las vegas beryllium
  • dave ball heating air choose
  • colt brennan and redskins preseason cheyenne
  • halle berry and monster's ball heaviest
  • greta scacchi nude gorilla
  • google google