Hopefully this does what you'd expect. -greg
Hey Greg! That works great from Terminal - thanks.
I changed your example to work with Sketchup, and by writing it like
this, I got it work under Sketchup as I want:
(The UI.messagebox put up a dialog box, similar to a javascript alert()
box )
require 'sketchup.rb' ;
include UI # <== this is the key to getting this to work
messagebox "Regular Messagebox..." ;
module UI
extend self
alias_method :messagebox_old, :messagebox
def messagebox (string)
puts "aliased method: #{string}"
end
end
messagebox "this should show up in the console" ;
module UI
alias_method :messagebox, :messagebox_old
end
messagebox "Back to normal" ;
In the above case, I get a popup, then a message to the Ruby console,
then a popup. Perfect.
However, from all my code, I typically never "include UI" and write
scripts like thi, qualifying the messagebox method with UI.messagebox...
require 'sketchup.rb' ;
UI.messagebox "Regular Messagebox..." ;
module UI
extend self
alias_method :messagebox_old, :messagebox
def messagebox (string)
puts "aliased method: #{string}"
end
end
UI.messagebox "this should show up in the console" ;
module UI
alias_method :messagebox, :messagebox_old
end
UI.messagebox "Back to normal" ;
Adding the UI. qualifier, the aliased method is never called and I get 3
popups.
Any ideas?