Hi
hendra kusuma wrote:> I''m creating desktop application using wxruby and encounter some
problem
> I need my application to be able to open only one for each frame
> is there any way to do this?
> I tried to include singleton but then my frame lost its contact with
> its parent
> (my frame class is inherited from WxFrame and I use initialize method
> to assign parent)
I''m not sure what you mean here - do you mean that only a single
instance of the application should be running at one time? If so, the
way would probably be to create some kind of lockfile on application
start: if the lockfile already exists, then the application is already
running.
If you want to have only one frame per file document, just keep a hash
as an instance variable of the Wx::App object, with the keys being the
file paths, and the values being the Wx::Frame objects. Then you can
check this hash to see if a Frame is already opened for a given
file.> also, I need to catch OnClose event
> how can I do that? I need to do something (delete temporary file)
> before the frame closed
> code example will be appreciated :)
Use evt_close, something like:
class MyFrame < Wx::Frame
def initialize
super
evt_close do | e |
delete_temp_file ...
e.skip
end
note that calling ''skip'' is important here, to allow normal
processing
to continue and the window to actually close
hth
alex