Keypress (down and up), mouse move, and mouse locking

Does anyone know how to do either of these functions in Daz script:

Detecting:
Key Down
Key Up
Mouse Movement

Overriding:
Mouse Locking (into the center)


Where could I find out info like this? The documentation is VERY limited, and the most info I get is from examining other scripts on some of the sites out there.

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,926
    edited December 1969

    Mouse movement isn't available to scripting - it would need a new plugin, which could then make the data available to scripts, but I don't think there's anything currently available. I'm not sure if it's possible to capture key-presses - I was thinking a text edit box might do the job, as a workaround, but it doesn't look like it.

  • edited December 1969

    Thanks to "Casual" for this:

    ed = new DzLineEdit( wDlg );
    connect( ed, "textChanged(const QString&)", textChanged );

    function textChanged( s )
    {
    if( s.length > 0 )
    {
    ed.text = "";
    switch(s.charAt(0))
    {
    case '1': bf1(); break;
    case '2': bf2(); break;
    case '3': bf3(); break;
    case '4': bf4(); break;
    case '5': bf5(); break;
    case '6': bf6(); break;
    case '7': bf7(); break;
    case '8': bf8(); break;
    case '9': bf9(); break;
    }
    }
    }

  • YudinEdYudinEd Posts: 90

    I think it is interesting to realize in DzListView (in DzListBox too).

    Signals - "mouseButtonPressed(int,DzListViewItem*,const QPoint&,int)"   or  "mouseButtonClicked(int,DzListViewItem*,const QPoint&,int)"

    var Dlg = new DzDialog();LV = new DzListView( Dlg );LV.minWidth = 500;LV.minHeight = 500;connect(LV,"mouseButtonPressed(int,DzListViewItem*,const QPoint&,int)" , mouseClicked );Dlg.exec()function mouseClicked (button, item, pos, col){		if( button == 1) print("left button")				if( button == 2) print("right button")		if (button==4) print ("mid button")        print ("y-"+ pos.y,"x-"+ pos.x)//  where is cursor? }

    You can try signals for your actions :

    "doubleClicked(DzListViewItem*,const QPoint&,int)" 

    "rightButtonClicked(DzListViewItem*,const QPoint&,int)"

  • a_s_lorda_s_lord Posts: 33

    The mouse click detection works, but I want it to trap a simple keystroke and print it.

    how do I set up wDlg, as per Casual's script to do that? So far I have (but throws an error at line 1):

     

    ed = new DzLineEdit( wDlg );

    connect( ed, "textChanged(const QString&)", textChanged );

    function textChanged( s )

    {

    if( s.length > 0 )

    {

    ed.text = "";

    switch(s.charAt(0))

    {

    case '1': print("1");

    }}}

     

     

  • YudinEdYudinEd Posts: 90
    edited April 2018
     wDlg = new DzDialog () ;// Dialog - your script textwDlg. exec()//text of your function

     

     

     

    Post edited by YudinEd on
  • a_s_lorda_s_lord Posts: 33

    Thats brilliant, thanks.

    I can now rotate a node using the numeric keypad

Sign In or Register to comment.