home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
drdobbs
/
1990
/
06
/
swaine.lst
< prev
next >
Wrap
File List
|
1990-05-02
|
3KB
|
107 lines
_PROGRAMMING PARADIGMS_
by Michael Swaine
[LISTING ONE]
on mousewithin
--
--hypertext technique by Steve Drazga, AnalytX
--if you use this in your scripts please include these 2 lines.
--
if the locktext of the target is true then
set locktext of target to false --unlock the field if it is
locked
end if
if selection is not empty then --something was selected
put selection into SelectedWord
if space is in SelectedWord then --user selected > 1 word
click at loc of target --so we will clear the selection
exit mousewithin --and exit to wait for another
selection
end if
--
--this is the section where you do something with the
selection
--You can bring up a pop up note or you can go to another
card.
--
end if
end mousewithin
[LISTING TWO]
on mouseUp
-- This code, placed in a button script, implements
-- Harvey Chang's hypertext trick. The user selects
-- any text in a field and clicks on the button.
-- The script first tries to use the selected text as a
-- hypertext link, then falls back to simple search.
doMenu Copy Text
put "Montreal Hypertext, Harvey Y Chang MD, 1988 Jan 16"
push card
go to Montreal Hypertext Demo
doMenu Find...
doMenu Paste Text
put " in field " & quote & "Title" & quote after message
do message
if the result is "not found" then
answer "not found in Titles: search text?" with "OK" or "No"
if it is "No" then
pop card
exit mouseUp
else
doMenu Find...
doMenu Paste Text
put " in field " & quote & "Text" & quote after message
do message
end if
end if
end mouseUp
[LISTING THREE]
on mouseUp
-- This is a scrolling field script. Its field must be locked.
-- It implements an index field, to be placed on the first
-- card of the stack to be indexed. This is the index card.
-- When the mouse is clicked inside the field, this script causes
-- a jump to the card corresponding to the line clicked on.
-- The line commented out uses the text in the line,
-- rather than its number, as the link.
go to card getLineNum(the mouseV)
-- find line getLineNum(the mouseV) of me in field keyword
end mouseUp
function getLineNum mouseVert
-- Returns the number of the line clicked on.
-- It works like this:
-- Subtracting the top of the field and its scroll from
-- the mouse's vertical location gives the
-- mouse's vertical location within the field.
-- Dividing this by the textHeight of the field & adding 0.5
-- converts pixel counts to line counts.
-- Rounding gives a value acceptable as a card number.
-- Note: although this technique should work with any font size,
-- turning on WideMargins will confuse the count.
-- To adapt this script to a non-scrolling field,
-- remove "+ the scroll of me" from the computation.
return round(((mouseVert - the top of me + the scroll of me) /
(the textHeight of me)) + 0.5)
end getLineNum