Can you load token Notes into an editable Frame?

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
Templar
Cave Troll
Posts: 65
Joined: Wed Sep 20, 2017 9:24 pm

Can you load token Notes into an editable Frame?

Post by Templar »

Hi,

I'm working on building character sheets for tokens.
I was wanting to have a tab which is just a big editable notes field where players can enter large amounts of extra info that does not have specific fields on the other character sheet tabs.
I assumed the best place to store this would be the Tokens "Notes" field.

So first I am unsure of how to access the notes field.
I'm also not sure how to make an editable text box within a frame.
Currently I have links to input macros to update fields.
I'm happy to do that here but still don't know how to load multiline inputs.

Any thoughts?

Templar
Templar

Phergus
Deity
Posts: 7132
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Re: Can you load token Notes into an editable Frame?

Post by Phergus »

In theory you could use the textarea html tag in a form but I don't know if the subset of HTML that is supported by Java includes textarea.

See the wiki page Introduction_to_Dialogs_and_Frames for an example of using html forms in dialogs.

User avatar
bubblobill
Giant
Posts: 167
Joined: Sun Jan 24, 2010 3:07 pm

Re: Can you load token Notes into an editable Frame?

Post by bubblobill »

Yes, you can use the textarea form input type.

Try using something like this
Spoiler

Code: Select all

[h: tokID=currentToken()]
[h: switchToken(tokID)]

[h: tokNotes=encode(getNotes())]
<!-- you need to clean the note text here to prevent unpleasant results. -->

[h: css='
    <style>
    <!--css goes here-->
    th {background-color:#CC32EE;
        color:#FFFFEE;}
    </style>']
[h: processorLink = macroLinkText("form.process@token","self","",currentToken())]

[h: updateButton='<input type="submit" name="update" value="Update Token">']
[h: notesTextArea='<textarea name="tokenNotes" cols= "89" rows="36">'+decode(tokNotes)+'</textarea>']

[h: frameHTML=strformat('
<html>
    <head>
        <title>Edit Token Notes</title>
        %{css}
    </head>
    <form action="%{processorLink}" method="json" >
    
    <input type="hidden" name="stored.args" value=macro.args>

	<table width=100%>
        <tr><th width=100% align=center>Your tab links/images/cells/whatever here.</th></tr>
        <tr><td align=right>%{updateButton}</td></tr>
        <tr><td align=center>%{notesTextArea}</td></tr>
    </table>
    
	</form>
</html>')]
  
[r,frame("MyFrameName", "width=300; height=700; temporary=0;"):	{[r:frameHTML]}]
Because people can have absolutely anything in their notes, you will need to clean/replace characters that will trip up the HTML, stripping out HTML tags and replacing " & ' should be enough generally.
Bubblobill on the forum.
@Reverend on the MapTool Discord Server

Responsible for less atrocities than most... I do accept responsibility for these though: SmartDoors, Simple d20 Framework - barebones, Drop-in: All 3.5 SRD Monsters, Drop in: Simple Character Editor, Battletech Framework

Post Reply

Return to “Macros”