-
Notifications
You must be signed in to change notification settings - Fork 8
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
Status text suggestion #133
Comments
To always suggest this, or to only suggest it if the status text can be detected to have been set at other events? Keep in mind only simple cases can be detected. If people set up utility methods to update the status text (I do that pretty consistently) then the indirection makes it difficult to detect. |
I was thinking always checking, as I can't think of any valid case when a tool shouldn't have a status text. Can't rubocop see if a method calls another method containing some given call? I always have a separate method for setting the status text that I call both in resume and activate. |
There is no simple lookup for that. It gets complex really fast. I've some times done one level of indirection checking for very common predictable patterns. |
Maybe this is a case where it's worth doing the complex one level check thing? # Bad. No status text at all.
# Unsure how common.
class MyTool
def activate
# ...
end
def resume(view)
# ...
end
end
# Bad. No status text on resume.
# Surprisingly common.
class MyTool
def activate
Sketchup.status_text =
if @some_state
"Mash some buttons and press some keys."
else
"Press some keys and mash some buttons."
end
end
def resume(view)
# ...
end
end
# Better. Functions corerctly but code repeats itself.
# Probably quite common.
class MyTool
def activate
Sketchup.status_text =
if @some_state
"Mash some buttons and press some keys."
else
"Press some keys and mash some buttons."
end
end
def resume(view)
Sketchup.status_text =
if @some_state
"Mash some buttons and press some keys."
else
"Press some keys and mash some buttons."
end
end
end
# Good.
# My preference.
class MyTool
def activate
update_status_text
end
def resume(view)
update_status_text
end
private
def update_status_text
Sketchup.status_text =
if @some_state
"Mash some buttons and press some keys."
else
"Press some keys and mash some buttons."
end
end
end
# Convoluted.
# Probably uncommon.
# I wouldn't mind if this cave a false positive.
class MyTool
def activate
some_method
end
def resume(view)
some_method
end
private
def some_method
update_status_text
end
def update_status_text
Sketchup.status_text =
if @some_state
"Mash some buttons and press some keys."
else
"Press some keys and mash some buttons."
end
end
end |
People often seem to forget setting the status text on tool resume, resulting in a blank status bar after having orbit, and no clue what the custom tool does. It would be nice if sketchup-rubocop had a suggestion for setting the status text on resume (and on activate if that is not already done).
The text was updated successfully, but these errors were encountered: