Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*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 2005

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

Search the Archive

Re: URL to be the value of ButtonData

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61319] Re: URL to be the value of ButtonData
  • From: John Fultz <jfultz at wolfram.com>
  • Date: Fri, 14 Oct 2005 22:23:12 -0400 (EDT)
  • Reply-to: jfultz at wolfram.com
  • Sender: owner-wri-mathgroup at wolfram.com

Murray,

The problem is that this button never goes through the kernel.  Only the FE 
sees the ButtonData[], and it doesn't know how to do StringJoin[].  If you 
don't mind your buttons round-tripping through the kernel, it would be a 
fairly simple matter to simply add

ButtonEvaluator->Automatic

but then, of course, if the kernel is in the middle of an evaluation, your 
hyperlink will hang until its evaluation comes up in the evaluation queue.  
But given that you want to do something even more sophisticated, there's no 
way to escape this unless you can push the sophistication back to the point 
of button creation rather than button execution.

I.e., if you could generate the buttons using something like the following:

With[{url = ComplexURLGeneratingFunction[]},
	ButtonBox["webmath", ButtonData:>{URL[url], None},
      ButtonStyle->"Hyperlink"]]

Sincerely,

John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.


On Mon, 3 Oct 2005 04:06:27 -0400 (EDT), Murray Eisenberg wrote:
> I'm trying to build up a local file URL to be the value of ButtonData
> for a ButtonBox.  (The file is in a subdirectory of the current
> notebook's directory, and I want to be able to refer to the target file
> no matter where I move the entire directory.)
>
> If I use an actual string as the argument in ButtonData:>{URL[...],
> None}, as in the following expression of that cell, it works just fine:
>
> Cell[TextData[ButtonBox["webmath",
> ButtonData:>{
> URL[ "file:///E:/Documents/WebMath.htm""], None},
> ButtonStyle->"Hyperlink"]], "Text"]
>
> However, if I try to build up the argument to URL in any way, even as in
> the following version where I simply join strings, then Mathematica
> reports a MathLink error occurred while receiving BoxData" after I
> convertthe expression to an actual input cell and click the hyperlink:
>
> Cell[TextData[ButtonBox[webmath",
> ButtonData:>{
> URL[
> StringJoin["file:///", "E:/Documents/", "WebMath.htm"]], None},
> ButtonStyle->"Hyperlink"]], "Text"]
>
> What's wrong and how can it be fixed?
>
> Version: 5.2 for Microsoft Windows (June 20, 2005)
>
> (I actually want to do something more sophisticated, namely instead of
> "E:/Documents/", use the value of a function ThisNBPath I've defined
> that will return the path to the directory of the evaluation notebook.)
>
> --
> Murray Eisenberg                     murray at 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



  • Prev by Date: Re: big integer for Range
  • Next by Date: Re: DSolve and matrix form of system of equations
  • Previous by thread: surface fitting question
  • Next by thread: Use strings in Mathematica, like in C?