+ Reply to Thread
Results 1 to 3 of 3

Thread: In GetObject : Esc key vs. Enter key pressed

  1. #1

    In GetObject : Esc key vs. Enter key pressed

    Hi All- I'm using Rhino.Input.Custom.GetObject() with a few command line options. All's working well except that I cannot see how to distinguish between an Enter (accept the settings and finish the command/script ) and an Esc (clean up, get out of command/script completely and don't modify anything, return the user to the command prompt). So far both keys finish the command. Not the end of the world, but it would be nice to be able to cancel the entire thing from this GetObject().

    Any ideas? Thanks....

    -Pascal

  2. #2
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,472
    Blog Entries
    19
    You are going to want to call AcceptNothing to allow for the enter key to act different than the escape key. Here's a short sample showing the difference

    Python Code:
      import Rhino
       
      def TestGetObject():
          go = Rhino.Input.Custom.GetObject()
          go.SetCommandPrompt("Select something")
          go.AcceptNothing(True) #this let's the enter key act different than esc
          while True:
              get_rc = go.Get()
              if get_rc == Rhino.Input.GetResult.Nothing:
                  print "you hit enter"
                  continue
              if get_rc == Rhino.Input.GetResult.Cancel:
                  print "you hit esc"
              break
       
       
      if __name__=="__main__":
          TestGetObject()

  3. #3
    Thanks Steve, that's perfect.

    -Pascal

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts