From: Mattia B. <mb...@ds...> - 2002-09-10 19:40:24
|
> -----Original Message----- > From: Mattia Barbon [mailto:mb...@ds...] > Sent: Saturday, September 07, 2002 12:18 PM > To: Everett, Toby > Cc: wxp...@li... > Subject: RE: [wxperl-users] Wx::ComboBox::SetValue ineffective when > wxCB_R EADONLY is set > > > > interactively, the value in $myvar changes. I'm not quite sure how it's > > > done internally. A widget->variable equivalent can be done like so: > > It uses magic (really! magic is used internally by perl to implement, > > among other things, tied variables, %ENV, lvalue subroutines, like > > pos() and substr(), ...). > I know of magic, just never messed around with the Perl internals (the ^^^^^ ^^^^^^^^^^^^^^ That's good, you gained a lot of mind-sanity this way... > closest I've gotten is writing a few dinky little XSUBs to speed string > manipulation for splitting stereo WAV files into mono ones and vice-versa). > I also found out that magic doesn't work perfectly when it comes to doing > slice manipulations on @ISA (Sarathy confirmed when I explained what I was > doing - he laughed and said I shouldn't do things like that to magic > variables:). > > > > Note that the calling syntax is Wx::TiedVariable::Set($widget, $$ref). > This > > > is intentional, because it would allow Set to be hooked into the Wx:: > > > hierarchy at the right point using something akin to > > > *Wx::RightHierarchyPoint::SetTiedVariable = \&Wx::TiedVariable::Set; > Then > > > you could just use $widget->SetTiedVariable(\$value); I just didn't > know at > > > what point in the hierarchy GetValue and SetValue became active. > > They are just for TextCtrl (well, and some other control has them, too); > Wx::ComboBox as well:) > > > it is probably easier to have an arbitrary method (say, FooBar), > implemented > > differently for each control, and use this method; > > e.g. > > *Ctrl1::Foobar = sub { one impl } > > *Ctrl2::FooBar = sub { other impl } > > And Wx::TiedVariable::Set calls FooBar instead of SetValue. > That makes sense. In the case of TextCtrl, you can even do > *Wx::TextCtrl::Foobar = \&Wx::TextCtrl::SetValue > right? I think so; it is probably better to name the method in some improbable way (say: Wx::TextCtrl::VarWatcher_FooBar ^^^^^^^^^^ Assuming your module is called VarWatcher > So should Wx::TiedVariable attach itself to Wx::Control? Do you want me to > write a prototype implementation, or given that the problem is so simple, > would you feel more comfortable writing it so that the code look and feel > matches the rest of wxPerl more closely? I don't know if this module belongs to wxPerl (I'm inclined to say not, I can be convinced otherwhise) I think it belongs to CPAN as an external module. Since you are interested in it, it is probably better if you write it. Regards Mattia |