April 7, 2016 at 11:53 am #68889
I’d like to know how it is possible to get the mouse event object in any method.
Some methods are having event as one of the arguments and thus there is no problem.
Other methods or user-created methods/functions could have a need of the event object BUT I don’t know how to declare/find it (if possible with Ctrlr/Juce/Lua).
Thx in advance for your advice!
EDIT 2017-04-20: I solved that one long time ago… Explanations below as answer to Mr Tor 🙂
April 20, 2017 at 5:13 pm #71882
- This topic was modified 5 years ago by goodweather. Reason: Solution found to the question some time ago
Could you please share what you’ve found about MouseEvent.
I saw in your panel you used MouseEvent.x and MouseEvent.x
What other possibilities are there? or where can I look to see what is provided with MouseEvent?
Thnx a lotApril 20, 2017 at 8:02 pm #71885
there are different things to take into account…
– you must create methods based on the different mouse event templates (componentLuaMouseDown, componentLuaMouseMove…) so you will get a first argument that is the component in focus and a second argument that is the event)
– as you know, Ctrlr is based on Juce and you will thus find a lot of info on many things in the Juce documentation available at https://www.juce.com/doc/classes. For mouse event, for example it is at: https://www.juce.com/doc/classMouseEvent
– you will also find the list of included Juce functions in the Ctrlr source code at https://sourceforge.net/p/ctrlrv4/code/HEAD/tree/nightly/Source/Lua/
In the JuceClasses folder you can find for example LMouseEvent.cpp that lists the available mouse functions.
So combining those 3 things and taking the time to read you will find and understand quite a lot. I learned Ctrlr like that without knowing anything about Juce…
Then as usual, trial and error + other panels + atom’s DEMO panels.
— Called when the mouse moves over a component
OnMouseMove = function(component,mouseEvent)
mousePosition = string.format (“x=%d y=%d”, mouseEvent.x, mouseEvent.y)
mousePositionX = mouseEvent.x
mousePositionY = mouseEvent.y
Good luck and good reading 😉April 20, 2017 at 9:13 pm #71887
Thnx a lot for your help.
However, I was at exactly the same pages 🙂
see the problem is I already found the following:
but the only place I was able to find for ex. how mods is used, like this:
(if MouseEvent.mods:isLeftButtonDown() then)
was your panel code 🙂
I can not find where that [:isLeftButtonDown()] is coming from so this applies to all other interfaces.
Juce mods class definition says “This will let you find out which mouse buttons were down” but I couldn’t find anything more there, such as how it’s used. 🙁
I would really appreciate if you could help with that as well.
Thnx a lot.
note: just before sending this message I ran MouseEvent.mods through the what function. was that where you found the isLeftButtonDown:function?
ThnxApril 21, 2017 at 1:51 pm #71891
I remember it took me some time to find and now I had to search again a bit 😉
Ctrlr, Juce and Lua are requesting a lot of attention and reading 🙂
So if you looked at the Juce MouseEvent class at https://www.juce.com/doc/classMouseEvent , you are very close…
One of the parameters concerned by a mouse event is the class ModifierKeys (you can click on that word in the Mouse event page) and being on that page (https://www.juce.com/doc/classModifierKeys) you have the description of that class including its functions.
There you will find all the different tests whereof isLeftButtonDown()
Good that you raised this question. I will add a chapter on this in the Step by Step guide 2.0 (now I’m working on it).May 20, 2017 at 6:09 pm #72188
do you have any information on how to use any of the following?
I’m using mousedrag on a label and want to know when the mouse is up.
Really have been pulling my hair on that for a while…
I think there might also be a way to set a method programmatcally, right?
what is component:mouseUp() do you know? Would it be possible to assign programmatically a mouseUp method to a component with
void mouseUp(Component&,MouseEvent const&)
ThnxMay 24, 2017 at 11:28 am #72196
- The forum ‘Programming’ is closed to new topics and replies.