Dear All, I want my app to save it''s window position so next time I run it, the window will place at the last position But I cannot use close event to save position since it is a tray application I plan to use on move window but cannot seem to find any documentation about it Any suggestion? Regards Hendra -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
Mario Steele
2010-Apr-20 15:29 UTC
[wxruby-users] how to save window position on frame move?
It''s easy to save the position of your window. And technically, you can use the onClose event, even with it being a Tray App. The method in which this works, is that you would need to return false from your window to prevent the window from being destroyed. An example of this: class MyWin < Wx::Frame def initialize() super(nil,-1,"Sample Hide, not close") evt_close(self,:on_close) end def on_close(event) @pos = self.position self.hide return false end end HTH, Mario On Mon, Apr 19, 2010 at 9:25 PM, hendra kusuma <penguinroad at gmail.com>wrote:> Dear All, > > I want my app to save it''s window position > so next time I run it, the window will place at the last position > But I cannot use close event to save position > since it is a tray application > > I plan to use on move window > but cannot seem to find any documentation about it > > Any suggestion? > > Regards > Hendra > -- > Suka linux? > Kunjungi blog saya http://penguinroad.blogspot.com > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-- Mario Steele Lieutenant 3 - Geo 99 XO - STO IFT Fleet Chief Engineer - Second Life http://www.iftcommand.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20100420/e47d8509/attachment.html>
penguinroad
2010-Apr-21 01:59 UTC
[wxruby-users] how to save window position on frame move?
I already know how to save the position but the reason for me not to use on_close event is because I am making a simple and personal desktop calendar with todo and event reminder and I am not likely to close it before I shutdown my computer therefore I need another event to save it what comes in my mind is an event when a window is moved but I cannot seem to find it any other idea? On Tue, Apr 20, 2010 at 10:29 PM, Mario Steele <mario at ruby-im.net> wrote:> It''s easy to save the position of your window. And technically, you can > use the onClose event, even with it being a Tray App. > > The method in which this works, is that you would need to return false from > your window to prevent the window from being destroyed. > > An example of this: > > class MyWin < Wx::Frame > def initialize() > super(nil,-1,"Sample Hide, not close") > evt_close(self,:on_close) > end > > def on_close(event) > @pos = self.position > self.hide > return false > end > end > > HTH, > > Mario > On Mon, Apr 19, 2010 at 9:25 PM, hendra kusuma <penguinroad at gmail.com>wrote: > >> Dear All, >> >> I want my app to save it''s window position >> so next time I run it, the window will place at the last position >> But I cannot use close event to save position >> since it is a tray application >> >> I plan to use on move window >> but cannot seem to find any documentation about it >> >> Any suggestion? >> >> Regards >> Hendra >> -- >> Suka linux? >> Kunjungi blog saya http://penguinroad.blogspot.com >> >> _______________________________________________ >> wxruby-users mailing list >> wxruby-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/wxruby-users >> > > > > -- > Mario Steele > Lieutenant 3 - Geo 99 > XO - STO IFT Fleet > Chief Engineer - Second Life > http://www.iftcommand.com > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20100421/9eb2945f/attachment-0001.html>
Alex Fenton
2010-Apr-21 06:01 UTC
[wxruby-users] how to save window position on frame move?
Hi Hendra On 21/04/2010 02:59, penguinroad wrote:> I already know how to save the position > but the reason for me not to use on_close event is > because I am making a simple and personal desktop calendar > with todo and event reminder > and I am not likely to close it before I shutdown my computer > therefore I need another event to save itMaybe Wx::ActivateEvent - http://wxruby.rubyforge.org/doc/activateevent.html You could use the evt_activate_app to detect when the whole application loses focus, and serialise the window state then. I have not tried this with tray-based apps, but there is a sample in etc/ that you could have a look at and try easily. best alex
hendra kusuma
2010-Apr-22 02:01 UTC
[wxruby-users] how to save window position on frame move?
On Wed, Apr 21, 2010 at 1:01 PM, Alex Fenton <alex at pressure.to> wrote:> Hi Hendra > > > On 21/04/2010 02:59, penguinroad wrote: > >> I already know how to save the position >> but the reason for me not to use on_close event is >> because I am making a simple and personal desktop calendar >> with todo and event reminder >> and I am not likely to close it before I shutdown my computer >> therefore I need another event to save it >> > > Maybe Wx::ActivateEvent - > http://wxruby.rubyforge.org/doc/activateevent.html > > You could use the evt_activate_app to detect when the whole application > loses focus, and serialise the window state then. I have not tried this with > tray-based apps, but there is a sample in etc/ that you could have a look at > and try easily. > >Thank you for the pointer I found Wx::MoveEvent and it works exactly as I need Thank you -- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20100422/2ba405e5/attachment.html>
Alex Fenton
2010-Apr-22 06:12 UTC
[wxruby-users] how to save window position on frame move?
On 22/04/2010 03:01, hendra kusuma wrote:> Thank you for the pointer > I found Wx::MoveEvent > and it works exactly as I needGood, I''m glad it works. I was cautious about suggesting MoveEvent because it occurs frequently when a Frame is, say, being dragged about by its title bar. So it''s not desirable to do lengthy operations (e.g. write to a File) each time it occurs. best alex
hendra kusuma
2010-Apr-22 06:23 UTC
[wxruby-users] how to save window position on frame move?
Well, thats exacly what I do write 2 lines to a file to save x and y position of my window I don''t know it it occurs frequently but somehow it do just fine thanks On Thu, Apr 22, 2010 at 1:12 PM, Alex Fenton <alex at pressure.to> wrote:> On 22/04/2010 03:01, hendra kusuma wrote: > >> Thank you for the pointer >> I found Wx::MoveEvent >> and it works exactly as I need >> > > Good, I''m glad it works. I was cautious about suggesting MoveEvent because > it occurs frequently when a Frame is, say, being dragged about by its title > bar. So it''s not desirable to do lengthy operations (e.g. write to a File) > each time it occurs. > > > best > alex > > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-- Suka linux? Kunjungi blog saya http://penguinroad.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20100422/236d1b40/attachment.html>