Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Disabling a button during the computation??

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15167] RE: [mg15037] Disabling a button during the computation??
  • From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
  • Date: Thu, 17 Dec 1998 00:27:46 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

Ville T Oikarinen
Wants to make a button that will have the same effect if it is depressed
once or a few times in rapid sequence.  I give you a toy button below
that does this. The key is to ensure the button has no function if it
was last depressed less than one second in the past.

First evaluate the code below in a notebook.

Note:
I understand there is be a more concise way to do this than
CellPrint[Cell[BoxData[ButtonBox[.....]]]] but I am just getting the
hang of this, and the code below is the best I could do.


(****** Code begins ***********)
LastUsed=0.0;

CellPrint[Cell[BoxData[ButtonBox[
 "Sample",
 ButtonEvaluator->Automatic,
 ButtonFunction:>(
   If[AbsoluteTime[]-LastUsed>1.,
     (LastUsed=AbsoluteTime[];
      NotebookWrite[InputNotebook[],
	Cell[TextData["The button was depressed."],"Print"]]
      )]
   )
]]]]

(****** Code ends ***********)

Then select the cell containing the button and make the menu selection:
  File -> Generate Palette from Selection

This gives you a palette containing the button.

Now you can use the button.


Cheers,
Ted Ersek


  • Prev by Date: Mathematica <-> Java???
  • Next by Date: Time Series package w v 3.0
  • Previous by thread: Disabling a button during the computation??
  • Next by thread: loading a notebook