Apple Newton Utilities Guide de l'utilisateur Page 632

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 942
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 631
CHAPTER 17
Additional System Services
17-16 Using Additional System Services
To add an action to the notify icon and display it, call the AddAction method as
in the following example:
myFunc := func() GetRoot():SysBeep();
theAct := GetRoot().notifyIcon:AddAction("Beep", myFunc,
nil);
You can remove an action by calling the KillAction method—for example, if
your task in progress completes while the
protoStatusTemplate view is
hidden, you should close the status view and remove the action from the notify
icon's menu. You need to save the result the
AddAction method returns. Pass this
object to the
KillAction method to remove the action from the notify icon’s list
of actions, as in the following example:
GetRoot().notifyIcon:KillAction(theAct);
Using the DoProgress Function 17
To provide user feedback during a lengthy operation, you can use the DoProgress
function to display a status view and call the function that implements that operation.
The
DoProgress function is suitable only for tasks that complete synchronously.
To report the progress of asynchronous work, you must display your own
protoStatusTemplate view and update it yourself, as described in “Using
protoStatusTemplate Views” beginning on page 17-18.
The
DoProgress function accepts as its arguments a symbol specifying the kind
of progress indicator to display (a thermometer gauge or a barber pole), an options
frame that allows you to customize the progress-reporting view further, and a
function that actually performs the operation on which you are reporting progress.
You must not allow the user to close the progress slip without cancelling the
progress-reporting operation—if the
DoProgress method sends status messages
to a nonexistent view, the Newton hangs. You must hide the Close button normally
provided by the
DoProgress method. You can do this by including a closebox
slot having the value
nil, in the options frame that you pass to DoProgress as
shown in the following code fragment:
local myOpts := { closebox:nil,
icon: kMyIcon,
statusText: kAppName,
gauge: 10,
titleText:"One moment, please…"}
The function you pass to DoProgress must accept as its sole argument the view
that displays
SetStatus strings to the user. For example, to report status while
Vue de la page 631
1 2 ... 627 628 629 630 631 632 633 634 635 636 637 ... 941 942

Commentaires sur ces manuels

Pas de commentaire