From: Everett, T. <TEv...@AL...> - 2002-09-09 20:15:12
|
-----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 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? 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? --Toby Everett |