PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Intercepting events with wxRuby/wxWidgets
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Intercepting events with wxRuby/wxWidgets

Réponse
 
LinkBack Outils de la discussion
Vieux 06/01/2008, 18h19   #1
Rainer
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Intercepting events with wxRuby/wxWidgets


Hello everybody,

I have a question concerning wxRuby/wxWidgets. I'm getting my feet wet
with a simple application that holds one Wx::Frame called VwX.

When my application gets closed, I want the user to decide whether the
app really will shut down. If it shuts down: Save the last changes or
not? Typical Yes/No/Cancel situation. So I do this: (Remark:
VwXEvOnClose(event) is the "on_close" event of my Wx::Frame):

def VwXEvOnClose(event)
dlg = MessageDialog.new(nil, "Save changes?", "MyApp",
Wx::YES_DEFAULT|Wx::CANCEL|Wx::YES_NO|Wx::ICON_EXC LAMATION)
command = dlg.show_modal
dlg.destroy

case command
when Wx::ID_CANCEL
event.veto

when Wx::ID_YES
save_my_changes
event.skip

else
event.skip
end
end

This works as it is supposed to. However, I noticed that the call to
"event.veto" might just as well be missing without any problems. OTOH,
the calls to "event.skip" are essential: If I dont call these, the
application simply won't shut down. Any ideas why the veto is
unimportant?




  Réponse avec citation
Vieux 06/01/2008, 20h26   #2
Alec Ross
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Intercepting events with wxRuby/wxWidgets

In message
<50925ed1-4211-4405-b6aa-0e73f896b227@e4g2000hsg.googlegroups.com>,
Rainer <wolf.rainer@gmail.com> writes
>
>Hello everybody,
>
>I have a question concerning wxRuby/wxWidgets. I'm getting my feet wet
>with a simple application that holds one Wx::Frame called VwX.
>

....

wxruby-users is a good place to post this kind of question.

HTH

Alec
--
Alec Ross
  Réponse avec citation
Vieux 06/01/2008, 21h16   #3
Alex Fenton
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Intercepting events with wxRuby/wxWidgets

Rainer wrote:
> Hello everybody,
>
> I have a question concerning wxRuby/wxWidgets. I'm getting my feet wet
> with a simple application that holds one Wx::Frame called VwX.


As noted, wxruby-users is a better place to ask questions specifically
about wxRuby.

> When my application gets closed, I want the user to decide whether the
> app really will shut down. If it shuts down: Save the last changes or
> not? Typical Yes/No/Cancel situation. So I do this: (Remark:
> VwXEvOnClose(event) is the "on_close" event of my Wx::Frame):


....

> This works as it is supposed to. However, I noticed that the call to
> "event.veto" might just as well be missing without any problems. OTOH,
> the calls to "event.skip" are essential: If I dont call these, the
> application simply won't shut down. Any ideas why the veto is
> unimportant?


The veto method only applies to close events; the documentation explains
that:

"If you don't destroy the window, you should call Wx::CloseEvent#veto to
let the calling code know that you did not destroy the window. This
allows the Wx::Window#close function to return true or false depending
on whether the close instruction was honoured or not."

hth
alex
  Réponse avec citation
Vieux 06/01/2008, 22h14   #4
Rainer
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Intercepting events with wxRuby/wxWidgets

On 6 Jan., 22:16, Alex Fenton <a...@deleteme.pressure.to> wrote:

> The veto method only applies to close events; the documentation explains
> that:
>
> "If you don't destroy the window, you should call Wx::CloseEvent#veto to
> let the calling code know that you did not destroy the window. This
> allows the Wx::Window#close function to return true or false depending
> on whether the close instruction was honoured or not."
>
> hth
> alex


Hello Alex,

this sounds like the method doesn't actually perform the veto, it just
informs the calling code that the window wasn't destroyed. Makes
sense, thank you. I only read the "short" documentation which states:

"Call this from your event handler to veto a system shutdown or to
signal to the calling application that a window close did not happen.
You can only veto a shutdown if wxCloseEvent::CanVeto returns true."

This sounded to me that there are cases when you actually perform the
veto. Case closed anyway: I will leave the method call in, of course.

Alec, thank you, too, for the hint with the wxruby-users mailing list.
I will reserve this for the harder cases, though, as this newsgroup
was absolutely fit for the task!

Thanks everybody,

Rainer




  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h55.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12351 seconds with 12 queries