User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

harlowe:named_hook [2017/06/20 02:08]
l created
harlowe:named_hook [2017/10/09 20:39]
Line 1: Line 1:
-====Named hooks==== 
-For a general introduction to hooks, see their respective markup description. Named hooks are a less common type of 
-hook that offer unique benefits. To produce one, instead of attaching a macro, attach a "​nametag"​ to the front or back: 
-[This hook is named '​opener'​]<​opener| 
-|s2>​[This hook is named '​s2'​] 
-(Hook nametags are supposed to resemble triangular gift box nametags.) 
-A macro can refer to and alter the text content of a named hook by referring to the hook as if it were a variable. 
-To do this, write the hook's name as if it were a variable, but use the ''​%%?​%%''​ symbol in place of the ''​%%$%%''​ symbol: 
-[Fie and fuggaboo!]<​shout| 
-(click: ?shout)[ (replace: ?​shout)["​Blast and damnation!"​] ] 
-The above [[harlowe:​click|(click:​)]] and [[harlowe:​replace|(replace:​)]] macros can remotely refer to and alter the hook using its name. This lets you, 
-for instance, write a section of text full of tiny hooks, and then attach behaviour to them further in the passage: 
-Your [ballroom gown]<​c1| is [bright red]<c2| with [silver streaks]<​c3|,​ 
-and covered in [moonstones]<​c4|. 
-(click: ?c1)[A hand-me-down from your great aunt.] 
-(click: ?c2)[A garish shade, to your reckoning.] 
-(click: ?c3)[Only their faint shine keeps them from being seen as grey.] 
-(click: ?​c4)[Dreadfully heavy, they weigh you down and make dancing arduous.] 
-As you can see, the top sentence remains mostly readable despite the fact that several words have [[harlowe:​click|(click:​)]] behaviours 
-assigned to them. 
-=== Built in names: === 
-There are four special built-in hook names, ?Page, ?Passage, ?Sidebar and ?Link, which, in addition to selecting named hooks, 
-also affect parts of the page that you can't normally style with macros. They can be styled using the [[harlowe:​enchant|(enchant:​)]] macro. 
-  * ''​%%?​Page%%''​ selects the page element (to be precise, the ''​%%<​tw-story>​%%''​ element) and using it with the [[harlowe:​background|(background:​)]] macro lets you 
-change the background of the entire page. 
-  * ''​%%?​Passage%%''​ affects just the element that contains the current passage'​s text (to be precise, the ''​%%<​tw-passage>​%%''​ element) and lets you, 
-for instance, change the [[harlowe:​text-colour|(text-colour:​)]] or [[harlowe:​font|(font:​)]] of all the text, or apply complex [[harlowe:​css|(css:​)]] to it. 
-  * ''​%%?​Sidebar%%''​ selects the passage'​s sidebar containing undo/redo icons (''​%%<​tw-sidebar>​%%''​). You can style it with styling macros, or use 
-[[harlowe:​replace|(replace:​)]] or [[harlowe:​append|(append:​)]] to insert your own text into it. 
-  * ''​%%?​Link%%''​ selects all of the links (passage links, and those created by [[harlowe:​link|(link:​)]] and other macros) in the passage. 
-(Note that, as mentioned above, if you use these names for your own hooks, such as by creating a named hook like ''​%%|passage>​[]%%'',​ 
-then they will, of course, be included in the selections of these names.) 
harlowe/named_hook.txt ยท Last modified: 2017/10/09 20:39 (external edit)