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

Re: [MacPerl] Buttons?



>Dear Perl Ppl,
>
>     Is there a way for a user to enter in a value to a text box and have
>them click on a button and have the button activate a funtion and the
>value in the text box be put in a variable?
>     I know quickdraw is cool, but I'm new at it.  What if I design some
>resources, like a WIND with some buttons or something?  I honestly have no
>clue on what to due, hence this e-mail, so any help would be appreciated.
>     Thanks for your time.
>
>                           * @=- s/Adam//g-=@ *

Hi Adam,

yes, there is a simple way. You can use one of the additional builtin
functions available only in MacPerl (take a look at the MacPerl.pod). In
this case, MacPerl::Ask(PROMPT, DEFAULT) will do the job:

___________

#!perl -w

$name  = MacPerl::Ask("Enter your first name:", "Adam");
if ($name) {
     # call a subroutine ...
     print "Name is $name\n"
} else { # user cancelled dialog
    # do something else ...
     print "user cancelled dialog\n"
}
___________


If you want to do your own window programming, you will need to know the
fundamentals of the Mac Toolbox (aka API - Application Programming
Interface), i.e. QuickDraw, Window Manager, Control Manager, Dialog Manager
... That's enough stuff to read for the next week or two ;-). I don't know
if the books are still available (first edition in the late 80's), but I
highly recommend the "Macintosh Revealed" series (Vol. 1 - 4) by Stephen
Chernicoff, Hayden Books. Although somewhat outdated, these books are still
very usefull for a general understanding. All examples in the books are
written in Pascal, the original language of the Mac API. If you are more
familiar with C/C++, you will surely find a Mac programming beginners book
dedicated to these languages. Another way is to look at the official
documentation "Inside Macintosh", which you can read online at the Apple
site. However, these books are aimed at professionals, so they may be hard
to understand.

Best regards

--Thomas



# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org