Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: syntax-aware selection in palette notebook

0 views
Skip to first unread message

Arnoud Buzing

unread,
Aug 31, 2010, 4:15:15 AM8/31/10
to
Not sure if this answers your question, but here are a few tips that
might be useful when working with palettes:

1. Use CreatePalette[expr] to generate palettes:

cp[] := CreatePalette[Button["Create Palette", cp[]]]

cp[]

That way you have access to the code to generate a palette and you can
modify that to make changes to your palette.


2. Under the 'Palettes' menu, there is a 'Generate Notebook from
Palette'. After using this on a (selected) palette, you can then
look at the underlying cell expression with the Cell -> Show Expression
menu item.


3. Assign the palette notebook object to a variable like so:

nb = cp[]

And then traverse the notebook expression to the BoxData and call
MakeExpression on it:

MakeExpression[NotebookGet[nb][[1, 1, 1]], StandardForm] // FullForm

--
Arnoud


On 8/22/10 7:10 AM, Murray Eisenberg wrote:
> If I have a palette notebook already created, how can I open it in a way
> that I (1) see the underlying expressions; and (2) can select in a
> syntax-aware manner, just like you can with input expressions in an
> ordinary notebook?
>
> Is there some way in Mathematica itself?
>
> In Workbench? If so, how do you open the palette notebook there that way?
>

Murray Eisenberg

unread,
Sep 1, 2010, 6:28:00 AM9/1/10
to
Yes, of course that's what one wants to do. Unfortunately, as my
original message stated, I did _not_ have the source for the palette,
just the resulting palette itself.

--
Murray Eisenberg mur...@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

Ingolf Dahl

unread,
Sep 4, 2010, 3:59:34 AM9/4/10
to
If with "syntax-aware" means that you do Ctrl+. , you might achieve the same
by

Button["SelectionMoveAllExpression", SelectionMove[EvaluationNotebook[],
All, Expression]]

But sometimes something is fishy with SelectionMove. Let us create four
additional buttons:

Button["SelectionMoveBeforeExpression",
SelectionMove[EvaluationNotebook[], Before, Expression]]

Button["SelectionMoveAfterExpression",
SelectionMove[EvaluationNotebook[], After, Expression]]

Button["SelectionMovePreviousExpression",
SelectionMove[EvaluationNotebook[], Previous, Expression]]

Button["SelectionMoveNextExpression",
SelectionMove[EvaluationNotebook[], Next, Expression]]

I have tested them on the expression

Sin[x] + Cos[y]

The first button, "SelectionMoveAllExpression", works as expected. To me it
seems a bit counterintuitive that a single bracket "[" is an expression, but
for Mathematica "everything is an expression", so OK with that.
The button "SelectionMoveBeforeExpression" also seem okey, unless the cursor
is placed after the letter "i" in Sin. Then the cursor is just moved to the
position after S. Is "i" in "Sin" an expression?
The button "SelectionMoveAfterExpression" does not do anything at all, while
the button "SelectionMoveNextExpression" does the job that
"SelectionMoveAfterExpression" should have done, with a similar behavior
inside words as "SelectionMoveBeforeExpression".
And the button "SelectionMovePreviousExpression" does exactly the same job
as "SelectionMoveBeforeExpression".

In the tutorial " Manipulating Notebooks from the Kernel" the word
"Expression" is said to mean "complete subexpression".

Can someone be pedagogic and help me in my ignorance?

Best regards

Ingolf Dahl

0 new messages