#505 Would like a way to prevent Enter from closing dialog when in single-line edit control

ooDialog.4.2.2
closed
ooDialog (102)
complete
1
2013-03-04
2012-12-19
No

In a dialog, hitting the Enter key automatically presses the default button, usually the Ok button. This is the way the dialog manager works.

It almost all circumstances it is not a good idea to interfere with that. Windows users come to depend on that behavior.

With a single-line edit control, if the user hits Enter the default button is pressed. In some rare cases, I would like to catch that Enter and invoke a method in the Rexx dialog. It would be nice to have some way, a easy way, to do that.

Discussion

  • Mark Miesfeld

    Mark Miesfeld - 2012-12-19

    Committed revision 8721. [r8721] implementation.

    Added a method to the Edit class -> wantReturn(methodName)

    Where methodName is the name of a method in the Rexx dialog to invoke when the Enter key press is detected. The key press is not passed on to the default Windows window procedure which prevents the dialog from closing automatically.

     

    Related

    Commit: [r8721]

    • Comment has been marked as spam. 
      Undo

      You can see all pending comments posted by this user  here

      Anonymous - 2016-06-15

      Can we have an example for implementation, please ?

      EDIT
      Find a working solution like

      editScanControl=self~getEditControl(IDC_SCAN)
      editScanControl~wantReturn(onEnter)

       
      Last edit: Anonymous 2016-06-15
      • Jon Wolfers

        Jon Wolfers - 2016-06-20

        Hi,

        I'm not quite sure what you are asking for. Does this help?

           dlg = .editDemoDlg~new
           dlg~execute
        
        ::requires "ooDialog.cls"
        ::class editDemoDlg subclass userdialog
        ::method init
        
          self~init:super
        
          if \self~createCenter(200, 50, 'Single Line Edit Control Demo')
          then do
            self~initCode=1
            return
          end
          self~demoEdit = 'Focus here and press enter'
        
        ::method defineDialog
        
           self~createEdit(100,10,10,self~sizeX-20, self~sizeY-40,,'demoEdit')
           self~createPushButton(IDCANCEL,self~sizeX-60,self~sizeY-20,50,15,,'Cancel')
        
        ::method initDialog
        
           ec = self~newEdit(100)
           ec~wantReturn('onEnter')
        
        ::method onEnter unguarded
        use arg ctrlID, editControlObj
        
           Say 'in onEnter method'
        
        return 0
        
         
  • Mark Miesfeld

    Mark Miesfeld - 2012-12-19
    • status: open --> accepted
    • assigned_to: Mark Miesfeld
    • pending_work_items: none --> doc
     
  • Mark Miesfeld

    Mark Miesfeld - 2012-12-21
    • status: accepted --> pending
    • pending_work_items: doc --> complete
    • milestone: ooDialog.4.2.1 --> ooDialog.4.2.2
     
  • Mark Miesfeld

    Mark Miesfeld - 2012-12-21

    Committed revision 8727. [r8727]

     

    Related

    Commit: [r8727]

  • Mark Miesfeld

    Mark Miesfeld - 2013-03-04

    Feature is in ooDialog 4.2.2

     
  • Mark Miesfeld

    Mark Miesfeld - 2013-03-04
    • status: pending --> closed
     


Anonymous

Cancel  Add attachments





Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks