ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperLicht
forum topic indicator Events (again)
person icon
bagg
Registered User
Quote
2010-10-29 19:20:07

Hi Niko
At first thanks for the update.I was hoping for some Lights but i guess i'll have to wait.
I have tried to develop some events but they are not working right.
What i am doing is this.(I don't know if the syntax is right)
engine.handleMouseDown = function (event)
{
mousedown (event)
};
What i want to do is to create a function with prototype the handleMouseDown. So the mousedown (event) is like this
function mousedown (event){
if (currentTool != null) {
currentTool.handleMouseDown(event);
}
}
The currentTool is selecred from a function that is selecting a tool depends on what button is pressed in the html.

function selectTool(opt_toolNumber) {
var toolNumber = opt_toolNumber;
if (toolNumber == undefined) {

currentTool = tools[0];
}

else
{
currentTool = tools[toolNumber];
}

}
The tools table is like this
tools = [
new SelectTool(),
new MoveTool ()
...........
]
And in seperate javascript files i have the function for each tool.
For the select tool is like this
function SelectTool() {
SelectTool.prototype.handleMouseDown= function(event){
var XPos = engine.getMouseX();
var YPos = engine.getMouseY();
alert (XPos+" "+YPos );
};
}
engine is a global value.
It gives always 0,0 no matter where i press the mouse.
Can you please help me on this?What am i doing wrong?

person icon
niko
Moderator
Quote
2010-10-30 10:42:46

What you are doing is not how it is supposed to be done. You need to o it like in tutorial 2:
http://www.ambiera.com/copperlic...
The part in there is about keyboard input, but it works in the same way with mouse input.
The function handleMouseDown is only supposed to be called by you if you do your own mouse input. If you overwrite it, the engine doesn't get the events anymore, that's your problem. See the tutorial, it gets explained in there.


Create reply:










 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






Copyright© Ambiera e.U. all rights reserved.
Contact | Imprint | Products | Privacy Policy | Terms and Conditions |