Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define constants for Tool onCancel reasons #552

Open
Eneroth3 opened this issue Oct 16, 2020 · 5 comments
Open

Define constants for Tool onCancel reasons #552

Eneroth3 opened this issue Oct 16, 2020 · 5 comments

Comments

@Eneroth3
Copy link

Currently we need to check for hardcoded integer values, or define these somewhere in our extensions. Ideally these should be defined by the SketchUp Ruby API.

CANCEL_ESC = 0
CANCEL_RESELECT = 1
CANCEL_UNDO = 2
@thomthom
Copy link
Member

Yes! I'm always defining these in my extensions!

@thomthom
Copy link
Member

We should do a "Constant all the Magic" cleanup sweep.

@DanRathbun
Copy link

Since these are relative to tool objects, ... I'd prefer ...

TOOL_CANCEL_ESC = 0
TOOL_CANCEL_RESELECT = 1
TOOL_CANCEL_UNDO = 2

... or ...

TOOL_REASON_ESC = 0
TOOL_REASON_RESELECT = 1
TOOL_REASON_UNDO = 2

@Fredosixx
Copy link

A few remarks

  • The value 1 is never received?
  • The value 2 is received for Undo and Redo

@DanRathbun
Copy link

Just a thought that if Sketchup::Tool were to be defined (instead of being abstract) as:

class Sketchup::Tool

  CANCEL_REASON_ESC = 0
  CANCEL_REASON_RESELECT = 1
  CANCEL_REASON_UNDO = 2
  CANCEL_REASON_REDO = 3

end

... then any explicit subclassing would inherit the constants.

This still gives programmers the option of subclassing or not.

Backstory: I dislike so many top level constants. The list of them is already too long.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants