Reset mousedown in javascript to the original behaviour?

Hi All,

I have a javascript routine where i add an ‘addEventListener’ for a mousedown routine with this command:
document.getElementByID(“myButton”).addEventListener(“mousedown”, myfunction, false);

If the function finished i remove the EventListener with this command:
document.getElementById(“myButton”).removeEventListener(“mousedown”, myfunction)

After that last command i thought the routine would return to it’s original behaviour, however after issuing this command the originaly working mousedown in e.g. a listbox doesn’t work anymore.

Any idea how i can restore the original behaviour?

TIA,
Andre

Don’t modify it in the first place.

That’s not realy the answer i was waiting for, maybe answering the second place will be closer.

OK lets try this one

You cant get there from here

Creating a WebSDK control might serve you better than trying to do this

It’s a piece of code in the WebSDK wrappercontrol.

Let’s zoom out.
What are you trying to accomplish with your WebControlWrapper?

Also, I’m confused as to how attaching a listener to your own item is messing up the framework listener on a listbox.

I want to display mousecoordinates without traveling forward and backward to the server. The button should enable and disable the functionallity. Thus it’s a local activity on the browser and shouldn’t interfere with server actions.

+1

Okay what it sounds like you’re doing is attaching to the mouse, not the button - that would be far more likely to interfere with the framework. The problem isn’t in the two functions you’ve shown above, it’s in whatever your “myfunction” is that tracks the mouse position.

myfunction does nothing more than realtime change the innerHTML of 2 textfields.

Post it, perhaps there’s something you’ve overlooked?

It would be immensely helpful to have access to all of the javascript you’re trying to use.
Otherwise I have to agree with the engineers, don’t mess with it :stuck_out_tongue:

function showCoords(event) {
if (md == true){
var pX = event.pageX;
var pY = event.pageY;

    var coords1 = "page - X: " + pX + ", Y coords: " + pY;
    
    document.getElementById("demo").innerHTML = coords1;
 }

}

[quote=326055:@Andre Kuiper]I want to display mousecoordinates without traveling forward and backward to the server. The button should enable and disable the functionallity. Thus it’s a local activity on the browser and shouldn’t interfere with server actions.
[/quote]
As you’ve discovered it does meaning and shouldn’t interfere with server actions. is not a safe assumption to make

if there isn’t one already installed by the web framework you can just set it to nil to stop the one you’ve installed. If there is one already setup by the web framework, save it off to some local javascript variable to save it when you replace it, and then put it back when you’re done.

Instead of using a listener which intercepts the event, and can impair the framework, use onmousedown for the control, which you add with setAttribute.

@Michel Bujardet and @James Sentman thanks for these suggestions, i will try both options and let you know what i am doing.

@Norman Palardy [quote=326066:@Norman Palardy]As you’ve discovered it does meaning and shouldn’t interfere with server actions. is not a safe assumption to make[/quote]
IMO the routine to reinstall the original behaviour should be documented. Catching the mouseevents on a webapp is such a basic ability that it is not understandable that it is covered in secrecy. Using the mouseevents in a javascript should be allowed without to fear that the serveractions are hindered.

Using a control local event is more OOP and less dangerous. In pure HTML where you are actually the master of all things, a global listener is OK. But when you do this inside a Xojo Web App, or by the same token, any web app that relies on JavaScript, you compete with that app’s framework.

I don’t feel it is up to Xojo to teach you how to reinstate their listeners you are not supposed to snatch in the first place.

Interfering with the Javascript event system of the Xojo web framework is not a supported operating mode.

It’s not my intention to snatch in to Xojo framework but there isn’t another way AFAIK to get some gain in performance. In fact by making the controlwrapper available Xojo promotes the use of javascript including reacting on mouseevents. The poor performance of XOJO webapps and lacking controls force you to use it.

Personaly i more and more get the feeling that Xojo web is totally without support!