Footnotes in scrolling text fields

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Footnotes in scrolling text fields

Post by montymay » Thu Sep 18, 2014 2:45 am

I cannot find this question in the forum. I am writing a ebook on law in which I cite sources (court cases, statutes, and attorney general opinions) for statements. Using linked superscripted consecutive numbers at the end of statements seems the method to use, as in a printed book, but the footnote numbers are linked text. It seems to me that a mouseEnter handler must be put into the script in the locked field containing the text. When the reader put the cursor over a superscripted, linked footnote number, I want a small field to pop up near it in which the source is stated, also in linked text, so that the user can click the text and open the actual source, a PDF file or a web page. Hoping I have not overlooked the solution, I thank you for your suggestions.

Monty

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Footnotes in scrolling text fields

Post by dunbarx » Thu Sep 18, 2014 3:17 am

Hi.

Only a quick read on your post, but does the "mouseText" help you here?

Craig Newman

montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Re: Footnotes in scrolling text fields

Post by montymay » Thu Sep 18, 2014 5:06 am

Hello Craig

Your suggestion to use the mouseText function seems to be the answer, but nothing happens when my mouse hovers over linked text in a locked field:

Code: Select all

on mouseenter
if the style of mousetext is "group" then
answer "Daisy" 
end if
end mouseenter
Of course, I want a field with the text of the footnote to appear, not a dialog box. Would the following be the correct script?:

Code: Select all

if the style of mousetext is "group" then
put the mousetext into vFootnote  -- mousetext should return the number of the footnote, I think
show fld vFootnote
end if


Thank you for any further suggestions.

Monty

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Footnotes in scrolling text fields

Post by Klaus » Thu Sep 18, 2014 12:36 pm

Hi Monty,

well "mouseenter" will NOT do what you want!
This message will get fired as soon as the mouse enters (sic!) the RECT of the field
and at that time it is unlikely that there is already TEXT under the mouse! :D

Use "mousemove" instead, that is being sent continuously while the mouse is moving over the field:

Code: Select all

on mousemove
  if the style of THE mousetext = "group" then
     put the mousetext into vFootnote  -- mousetext should return the number of the footnote, I think
     show fld vFootnote
  end if
end mousemove
Best

Klaus

montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Re: Footnotes in scrolling text fields

Post by montymay » Thu Sep 18, 2014 6:04 pm

Hello Klaus,

Thank you for pointing out the error and the correct handler, but now I have another problem. After reading the dictionary entry for mouseMove and seeing its example, I revised my script for the field containing my body text with footnotes:
on mouseMove
if the mouseChunk is not empty and "link" is among the items of the textStyle of the mouseChunk then
put the mousetext into vFootnote
answer vFootnote
show fld vFootnote
end if
end mouseMove
Lets say my superscripted footnote number, which is styled as link, is "1". My hidden field representing the footnote is named "1". Upon hovering the mouse cursor over the footnote number, I get the dialog box and it returns "1" (yay! :D), but after I close the dialog box I get an error ( :( ). The script editor says "no such object," meaning, I suppose, there is no field on the card that has the name "1". But there is a field on the cd named "1". :x I get the same result if I add "of this cd" to the line.

Sorry if I am overlooking the obvious, and I don't want you or any other experienced developer to do my work for me, but maybe the fix is obvious.

Monty

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Footnotes in scrolling text fields

Post by Klaus » Thu Sep 18, 2014 6:38 pm

Hi Monty,

1. do not use any ANSWER dialog in a MOUSEMOVE handler!
Bad idea, which might cause an ENDLESS loop if you have bad luck and
surely will produce strange results as oyu have experienced!

2. MOST important:
Do not use NUMBERS as names for Livecode objects, that will irritate the engine,
because the engine sees this as the NUMBER (layer) of the object and niot its name!
Add at least any character like "f1" or whatever!
...
put the mousetext into tFootNote
show fld ("f" & tFootNote)
...


Best

Klaus

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Footnotes in scrolling text fields

Post by jmburnod » Thu Sep 18, 2014 7:07 pm

Hi monty,
I tested your script and it works for me.
The script show the field named "2" when the mousetext = "2", but I think a number is not a good name for a control.
if you put "1" into a variable tMyName
If you call field tMyName you call the first fld not the field named "1"

To go further, we need some informations about your project.

For exemple:
Do you think have one field for each note ?
Best regards
Jean-Marc
https://alternatic.ch

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9655
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Footnotes in scrolling text fields

Post by dunbarx » Thu Sep 18, 2014 9:32 pm

Here is some stuff to play with. Make a large field with some text. Make another small field named "footnote". Put this in the script of the large field:

Code: Select all

on mouseMove
      put the mousetext
      set the tooltip of me to the mouseText
   
   --put the mouseText into fld "footNote"
   --show fld "footnote" at item 1 of the mouseLoc + 50 & "," & item 2 of the mouseLoc + 20
end mouseMove

--on mouseLeave
   hide fld "footNote"
end mouseLeave

--on mouseEnter
   show fld "footnote"
end mouseEnter
Play with the first two lines in the "mouseMove" handler, just to see how they work. Now comment those two lines, and uncomment the last two lines, as well as with the other handlers. Now figure out a way to make that footnote field stay put if you want to click in it. Write back with how you did it.

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”