Dynamic tooltips and status text

All use of class/module variables should declare (or define them,) near the top of the code.
If you reference them, or ruby encounters them before they have been initialized, a Runtime error occurs.

I do this even when I will later set them to a command or a string, etc.
It is a good place (at the top of the code) to put a comment explaining what the variables will be used for.

@@rotate_cmd = nil # UI::Command instance for rotator tool

FYI, definition of class/module variables cannot use the ||= syntax because that expands to

@@var = @@var || value

… which would be referencing @@var just to the right of the assignment operator, before it is initailized.


BTW,… did we just abandon the previous topic ?
Editing toolbar tooltips on the fly

1 Like