[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Controls



I'm new on the list, but I've scanned the last 6 months of archives and 
don't think that some things related to the Controls Toolbox module have 
been clarified, or whatever. Alan Fry had a question about passing procs 
to TrackControl that I never saw an answer for, posted anyhow.

I worked this stuff through about three months ago when doing a document 
window class that inherits from MacWindow. Scrollbars, window-edge 
goodies, and so forth. I ran into the same problem Alan had:

'Mac::Controls::TrackControl: Last argument must be procedure, 0, or -1'

To get everything working I ended up modifying Controls::track() a fair 
bit, too, mainly to save the old control value before calling 
TrackControl(), and then passing it to hit(). But I won't do more than 
mention that in passing. While we're at it, I'm curious about the logic 
in 
TextEdit::click(), where the PtInRect test doesn't encapsulate TEClick, 
and in TextEdit::redraw(), the InsetRect + FrameRect sequence sure looks 
like a debugging holdover. :-)
 
To get to the subject Alan raises, though, let me point out some dubious 
aspects of TrackControl as it appears in Controls.xs. One, the
 
if (part > 127 || part < 250)
 
test is never going to fail.  So maybe && was intended.  In any case, 
what's leading to the error above is the function 
"looks_like_number(actionProc)".  If you look at the source in "sv.c" 
you'll see that _anything_ that contains only (0..9,'e','E','.','+','-') 
in 
a legal sequence will be trapped by the
 
else if (SvNIOK(actionProc) || looks_like_number(actionProc))
 
test, leading to the croak when it doesn't also match 
(ControlActionUPP)-1.  
Try converting just looks_like_number() to an XSUB, and start throwing 
stuff at it. Only strings containing characters which cannot be put into 
a floating-point representation are flagged as non-numbers by this 
function. I haven't found a procedure pointer yet which didn't look like 
a number to this beast. So it's a not a useful test where it's used here.

It seems to me that just the SvNIOK macro should do the trick. That's how 
I implemented it.

I'll leave it at that, since I have no way of knowing whether this has 
been addressed. My solution involved fixing a MacPerl .xs file, so apart 
from my own projects I can't take it any further.

Regards from Nova Scotia


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch