How to stop the "Enter" key from activating the first button in the dialog?

How do I stop the "Enter" key from activating the first button on the dialog?

Tests:

run script, press the enter key.

run script, click on any text box, type something, press the enter key.

 

// Create Dialog Boxvar Form = new DzDialog();Form.caption = "The 'Enter' key test.";var count1 = 0;var count2 = 0;var lineEdit = new DzLineEdit(Form);lineEdit.setGeometry( 10, 10, 100, 23 );// Create and define DzPushButton: 'pushButton'var pushButton = new DzPushButton( Form );pushButton.setGeometry( 120, 10, 75, 23 );pushButton.text = "Clicked 0";pushButton.objectName = 'pushButton';connect( pushButton, "clicked()", function() {	pushButton.text = "Clicked "+(++count1);} );connect( pushButton, "released()", function() {	pushButton.text = "Clicked "+(++count1);} );connect( pushButton, "pressed()", function() {	pushButton.text = "Clicked "+(++count1);} );var lineEdit2 = new DzLineEdit(Form);lineEdit2.setGeometry( 10, 50, 100, 23 );var pushButton2 = new DzPushButton( Form );pushButton2.setGeometry( 120, 50, 75, 23 );pushButton2.text = "Clicked 0";pushButton2.objectName = 'pushButton2';connect( pushButton2, "clicked()", function() {	pushButton2.text = "Clicked "+(++count2);} );var bResult = Form.exec();if( bResult ) {	// Do if dialog box was accepted} else {	// Do if dialog box was canceled}

 

Comments

  • Well, the tab key will advance between the elements of the dialogue, though focus has to be on the second button for it to register the presses. I don't immediately see a way to set focus, which is what you want.

  • Ah, I was looking in the wrong place - http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/pushbutton_dz is where I should have been, but I was just loking at the generic dzButton. Fortunately Rob saw this. DzPushButton has a default member - unfortunately, because default is a reserved word you can't set it in the usual manner. What you need is

    pushButton2[ "default" ] = true;

    to set pushButton2 as the default. (I haven'y tested to see if you can make all buttons have default set to false.)

  • FamilyUFamilyU Posts: 38

    Thanks, I checked out the "default" property. But  it's still not what I need.  I don't want the "Enter" key to be tied to any working buttons.  

    After some testing, I just made a hidden button as the first button on the panel with no events tied to it.

    It's working.  Not sure if it the correct way to do it.

    var Form = new DzDialog();

    var pushButtonFirst = new DzPushButton( Form );

    pushButtonFirst.setGeometry( 10, 10, 0, 0 );

     

    If there is a better way. please let me know.

    Thank you for your response.

     

  • barbultbarbult Posts: 24,244

    Something changed in DS 4.12 that is affecting existing Daz Store products in an adverse way in this regard, too. For example, V3Digitimes product Iray Light Manager Pro script now activates the "More Information About This Tool" button every time I press Enter after editing a numeric field in the script. This does not happen in DS 4.11. 

  • barbult said:

    Something changed in DS 4.12 that is affecting existing Daz Store products in an adverse way in this regard, too. For example, V3Digitimes product Iray Light Manager Pro script now activates the "More Information About This Tool" button every time I press Enter after editing a numeric field in the script. This does not happen in DS 4.11. 

    Not really on topic for this thread, but that is almost certainly related to the stuff in the change log about default buttons in the basic dialogue.

  • TotteTotte Posts: 13,970
    FamilyU said:

    Thanks, I checked out the "default" property. But  it's still not what I need.  I don't want the "Enter" key to be tied to any working buttons.  

    After some testing, I just made a hidden button as the first button on the panel with no events tied to it.

    It's working.  Not sure if it the correct way to do it.

    var Form = new DzDialog();

    var pushButtonFirst = new DzPushButton( Form );

    pushButtonFirst.setGeometry( 10, 10, 0, 0 );

     

    If there is a better way. please let me know.

    Thank you for your response.

     

    i did this seems to work
     

    this.wdummybutton = new DzPushButton(this.wDialog);this.wdummybutton.x = -9999;this.wdummybutton.y = -9999;

     

  • PraxisPraxis Posts: 254

    (Just for completion) You could also do this on each DzPushButton:

    pushbutton.autoDefault = false;

    But I  prefer Totte's elegant solution!

     

  • So, can anyone explain in plain language what I need to do so that I can press "Enter" in any window and this damn help is not called up, please?

    Just earlier (in previous versions) I could enter any values, for example, in Parameter Settings and pressing "Enter" I confirmed all the changes and the window closed.
    ​And now, out of habit, I press "Enter" but instead I get a help function, which I absolutely don't need!
    I could not find how to change this in the settings of Workspace> Customize.

  • Richard HaseltineRichard Haseltine Posts: 100,905

    So, can anyone explain in plain language what I need to do so that I can press "Enter" in any window and this damn help is not called up, please?

    Just earlier (in previous versions) I could enter any values, for example, in Parameter Settings and pressing "Enter" I confirmed all the changes and the window closed.
    ​And now, out of habit, I press "Enter" but instead I get a help function, which I absolutely don't need!
    I could not find how to change this in the settings of Workspace> Customize.

    This thread is about scripting. The issue with default dialogues, which shold I think be fixed in the beta, is better discussed in the main DS forum.

Sign In or Register to comment.