mouse interactions

Can somone nudge me in the right direction. I'm trying to find the object under my mouse curser, but have no idea what area I should be searching in in the API reference for more info about this. 

Comments

  • If you want direct mouse interaction you probably need to be looking at the plug-in SDK, though I think casual did/does have a plug-in that gives some mouse info to a script.

  • BradCarstenBradCarsten Posts: 856
    edited October 2017

    Oh, I never knew that even existed. Thanks, I'll take a look at it. 

    Post edited by BradCarsten on
  • YudinEdYudinEd Posts: 90
    edited October 2017

    Maybe this will help you - my example with  DzListView

    https://www.daz3d.com/forums/discussion/175031/4-9-4-broke-dzlistview-clicked

     

    Post edited by YudinEd on
  • BradCarstenBradCarsten Posts: 856
    edited October 2017

    Thanks for the suggestion. I was playing around with signals and wrote this just to get a feel for it: 

    connect(App, "mouseEvent()",mEvent());function mEvent(){	print("test");}

     

    It prints: "test", but that doesn't trigger again when click around the viewport. How do you get that to keep triggering without executing the script again? 

    Post edited by BradCarsten on
  • YudinEdYudinEd Posts: 90

    connect(App, "mouseEvent()",mEvent());

    Error in script. In this string function hasn't  (). Correct - connect(App, "mouseEvent()",mEvent);

    Script write now " true" :) and nothing more

  • hphoenixhphoenix Posts: 1,335

    I think you are expecting something that is not what Scripting is designed to do.

    A script doesn't (normally) run concurrently with the main application.  It runs separately, and runs to completion.  It is not a persistent entity in the application.

    There are ways to keep the script running while still interacting with the main application, but they are VERY problematic.  And they tend to slow the entire application down.  If you dig down through the older forum posts here, you can find some ways it is accomplished (it involves using App.ProcessEvents() in an infinite loop.)  But it is very much NOT recommended.

    Mouse events are available to scripts to allow you to develop script dialogs that react to mouse events outside of normal UI elements, and to develop new UI elements.  NOT to allow you to try to capture stuff happening in the main Application UI.

    If you need to respond to things happening in the main UI, you need to look at the Plugin SDK, and develop an actual C++ plugin that is properly connected to the events happening in the DS application.  Look at the various SDK samples, and work with one that uses a 'pane' as your base.

  • Thanks everyone for all the input. That makes sense. I was hoping I wouldn't have to start at the beginning again and learn c++, but it looks like I may have to take a deep breath and wade in. 

  • EsemwyEsemwy Posts: 578

    You might try using DzCallbackMgr to add a callback to a specific event. I have some example code, but I’m not at home right now. I’ll see what can find if you haven’t figured out before I get a chance. 

  • TotteTotte Posts: 13,974

    Hello,

    I have figured out how to get mouse clicks (same as above, connect the mouseEvent on the App object, but I really cannot find how you get the current mouse coordinates? There are a lot of methods on DzWidget about GlobalToLocal() etc, but getting the current mouse x,y seems hard. I've skimmed through most of the objects I though could have anything to do with it, but nope. Anyone knows how to get that?

     

Sign In or Register to comment.