Code Monkey home page Code Monkey logo

Comments (6)

lovasoa avatar lovasoa commented on September 4, 2024

Hello,
Yes, you can use any DOM event as a listener, just add it to the compiledListeners property of your tool.

	var myTool = {
		"name": "MyNewTool",
		"shortcut": "m",
		"listeners": {
			"press": startLine,
			"move": continueLine,
			"release": stopLineAt,
		},
               "compiledListeners": {
                       "dblclick": myListener
               }, ...

For hover, I would use the existing move listener, though. See for instance the eraser.

The relevant part of the code you may want to read is here : https://github.com/lovasoa/whitebophir/blob/master/client-data/js/board.js#L497-L513

edit : fixed example. The property name iscompiledListeners, not computedListeners

from whitebophir.

Sharath-GitBan avatar Sharath-GitBan commented on September 4, 2024

Hello, thank you for your response, I added 'click' listener to the tool, but when I click after selecting the tool, even listener is not triggered.

from whitebophir.

lovasoa avatar lovasoa commented on September 4, 2024

If you publish your fork, I'll have a look at it if you want.

from whitebophir.

Sharath-GitBan avatar Sharath-GitBan commented on September 4, 2024

function myListener(){
console.log('in click listener')
}
Tools.add({
//The new tool
name: "Resize Element",
icon: "✥✥",
shortcut: "R",
computedListeners: {
click: myListener
},
listeners: {
press: press,
move: move,
release: release
},
//draw: draw, //save move text to server
mouseCursor: "crosshair"
});

from whitebophir.

Sharath-GitBan avatar Sharath-GitBan commented on September 4, 2024

It should be compiledListeners not computedListeners

from whitebophir.

lovasoa avatar lovasoa commented on September 4, 2024

Oh, I see. I wrote the right name in my message above, but made a mistake in the example.

from whitebophir.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.