[patch - New Feature] Input Function enhancements
Moderators: dorpond, trevor, Azhrei
[patch - New Feature] Input Function enhancements
As promised, here's the modified input function. I was busy this week else I would have released it sooner. Apart from the promised text area, I also thought to open the actual window model itself for MTScript users to manipulate. Please test it out so I can fix whatever's broken; though I think everything should be fine. In order for the new JSON functionality to work, however, I had to expose some private functions found in the JSON class. IDK how Azhrei and the others feel about this, but I took my cue from other classes that seemed to have had their private methods exposed as well. Anyway, to the the meatier stuff:
New functionality:
1. TEXTAREA input type - I didn't need to break the grid model as I opted for a simple containment scheme. It follows the basic input model of variable, value, prompt, and options. Value will hold the eventual contents of the text area. Options are ROWS and COLS, which sets the depth and breadth of the text area, SPAN works like it always has and is set to false by default.
Example: [input("txtAreaVar | Content | Prompt | rows=5 cols=50")]
Edit: For those who don't know, you can do ctrl+enter to emulate hitting enter on another input type and ctrl+tab and shift+tab for traversal. These were the defaults MT has been using along with what most are used to.
2. JSON - works like PROPS but is more flexible. Guided by the suggestions of aliasMask, it allows the passing of json Arrays or Objects for manipulation in an input window. The value parameter holds this passed information, of course. Options are SPAN (default=false), which only works/is meaningful for JSON Objects since I suppressed prompts for JSON array items, seeing that these are merely junk and are discarded after the transaction, and using the JSON input type is mainly focused on manipulating/creating values. WIDTH sets the text field length for all items.
Example: [input(strformat("jsonVar | %s | Prompt type | width=50", json.set("{}", "a", 1, "b", 2, "c", 3)))]
3. WINDOW - Allows MTScript users to manipulate the input window a bit. Hence, it is important to note that it is not an input type; even if it follows the input function form. The variable parameter is useless and inaccessible to MT scripters. The value parameter holds the eventual title of the window. The prompt will be the window's tool tip text. Owing to its nature of not being an input type, the code for setting prompts is skipped for aesthetic purposes, among other things. Options are as follows:
a. TYPE accepts values of -1 (plain message), 0 (error message), 1 (information message), 2 (warning message), and 3 (question message). Default is set to -1, what everyone has been using so far. Basically, this is used for aesthetics, to have that L&F icon on display depending on the type chosen.
b. CHOICES accepts values of 0 (Yes, No), 1 (Yes, No, Cancel), and 2 (Ok, Cancel). Default is set to 2, what most MT users are familiar with. More on this later.
c. OPTIONS accepts a string similar to the JSON array form, i.e. [a, b, c], to a maximum of 3 items (due to the nature of JOptionPane and how MT incorporated an HTMLPane). Each item in the "array" becomes the label for a particular button. OPTIONS overrides the CHOICES model; meaning even if a 2-button choice option is set, a 3 item OPTIONS parameter will result in a 3 button window. The only exception to this is when a blank set is passed, i.e. "[]"; here the input window reverts to whatever is set for CHOICES. Default for this is null, though this is non-impacting. Using this option parameter results in the input window becoming "customized" in nature. More on this below
Return values, default window types, "customized" mode
To avoid affecting existing MT scripts out there. The default return values are as follows:
a. Ok - returns 1 as it always has
b. Cancel - returns 0, as it always has
c. Yes - returns 1
d. No - returns 2
e Closing window through the 'X' - returns 0 for all window types including customized
f. Customized buttons - returns different values. 1 for the leftmost button, 2 for the middle, and 3 for the 3rd. This was intended to provide MT scripters with added capability a 3-button input window provides.
Example: [input("junkVar|winTitle|winToolTip|window|type=-1 choices=1 options=[Bacon, Eggs, Toast]")]
4. Radio - added the option SOF (short for SelectOnFocus). This accepts true or false values, set to false as default. What this does is, as the name states, select the radio button after it receives focus while tabbing through the input window; handy for input windows containing single radio button groups.
5 Props - added the WIDTH option to set the length for all prop fields.
Changes and Fixes:
1. In order for the new functionality to work, several functions in the JSON class were made public. Modified class included in the patch.
2. Fixed the bug where html content made tab traversal require 2 hits before moving on to the next component.
3. Set default value for text fields to a blank instead of 0
4. Other changes to make this work are found with comments in the code.
Do test this out and see if it's to your liking. I've made other stuff not related to this and will put it up shortly once I'm done with my newest drop-in. Please feel free to leave any questions or comments.
Thank you.
New functionality:
1. TEXTAREA input type - I didn't need to break the grid model as I opted for a simple containment scheme. It follows the basic input model of variable, value, prompt, and options. Value will hold the eventual contents of the text area. Options are ROWS and COLS, which sets the depth and breadth of the text area, SPAN works like it always has and is set to false by default.
Example: [input("txtAreaVar | Content | Prompt | rows=5 cols=50")]
Edit: For those who don't know, you can do ctrl+enter to emulate hitting enter on another input type and ctrl+tab and shift+tab for traversal. These were the defaults MT has been using along with what most are used to.
2. JSON - works like PROPS but is more flexible. Guided by the suggestions of aliasMask, it allows the passing of json Arrays or Objects for manipulation in an input window. The value parameter holds this passed information, of course. Options are SPAN (default=false), which only works/is meaningful for JSON Objects since I suppressed prompts for JSON array items, seeing that these are merely junk and are discarded after the transaction, and using the JSON input type is mainly focused on manipulating/creating values. WIDTH sets the text field length for all items.
Example: [input(strformat("jsonVar | %s | Prompt type | width=50", json.set("{}", "a", 1, "b", 2, "c", 3)))]
3. WINDOW - Allows MTScript users to manipulate the input window a bit. Hence, it is important to note that it is not an input type; even if it follows the input function form. The variable parameter is useless and inaccessible to MT scripters. The value parameter holds the eventual title of the window. The prompt will be the window's tool tip text. Owing to its nature of not being an input type, the code for setting prompts is skipped for aesthetic purposes, among other things. Options are as follows:
a. TYPE accepts values of -1 (plain message), 0 (error message), 1 (information message), 2 (warning message), and 3 (question message). Default is set to -1, what everyone has been using so far. Basically, this is used for aesthetics, to have that L&F icon on display depending on the type chosen.
b. CHOICES accepts values of 0 (Yes, No), 1 (Yes, No, Cancel), and 2 (Ok, Cancel). Default is set to 2, what most MT users are familiar with. More on this later.
c. OPTIONS accepts a string similar to the JSON array form, i.e. [a, b, c], to a maximum of 3 items (due to the nature of JOptionPane and how MT incorporated an HTMLPane). Each item in the "array" becomes the label for a particular button. OPTIONS overrides the CHOICES model; meaning even if a 2-button choice option is set, a 3 item OPTIONS parameter will result in a 3 button window. The only exception to this is when a blank set is passed, i.e. "[]"; here the input window reverts to whatever is set for CHOICES. Default for this is null, though this is non-impacting. Using this option parameter results in the input window becoming "customized" in nature. More on this below
Return values, default window types, "customized" mode
To avoid affecting existing MT scripts out there. The default return values are as follows:
a. Ok - returns 1 as it always has
b. Cancel - returns 0, as it always has
c. Yes - returns 1
d. No - returns 2
e Closing window through the 'X' - returns 0 for all window types including customized
f. Customized buttons - returns different values. 1 for the leftmost button, 2 for the middle, and 3 for the 3rd. This was intended to provide MT scripters with added capability a 3-button input window provides.
Example: [input("junkVar|winTitle|winToolTip|window|type=-1 choices=1 options=[Bacon, Eggs, Toast]")]
4. Radio - added the option SOF (short for SelectOnFocus). This accepts true or false values, set to false as default. What this does is, as the name states, select the radio button after it receives focus while tabbing through the input window; handy for input windows containing single radio button groups.
5 Props - added the WIDTH option to set the length for all prop fields.
Changes and Fixes:
1. In order for the new functionality to work, several functions in the JSON class were made public. Modified class included in the patch.
2. Fixed the bug where html content made tab traversal require 2 hits before moving on to the next component.
3. Set default value for text fields to a blank instead of 0
4. Other changes to make this work are found with comments in the code.
Do test this out and see if it's to your liking. I've made other stuff not related to this and will put it up shortly once I'm done with my newest drop-in. Please feel free to leave any questions or comments.
Thank you.
Last edited by Lee on Tue May 28, 2013 5:09 pm, edited 8 times in total.
My stuff for the community:
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
- CoveredInFish
- Demigod
- Posts: 3104
- Joined: Mon Jun 29, 2009 10:37 am
- Location: Germany
- Contact:
Re: [patch] Input Function improvements(?)
Patch uploaded anew. Cleaned up some comments and the like. Hopefully, this didn't affect the actual code in any way.
My stuff for the community:
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
Re: [patch] Input Function improvements(?)
Cool, that'll actually work. I was afraid the syntax of the json would be a problem, especially for quotes.Lee wrote:Example: [input(strformat("jsonVar | %s | Prompt type | width=50", json.set("{}", "a", 1, "b", 2, "c", 3)))]
I'm going to use the heck out of TEXTAREA. WINDOW seems interesting and I'll probably use the customize version. SOF is interesting, but on mouseover IMO could cause selection problems.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: [patch] Input Function improvements(?)
I've tried and it accepts [input('jsonVar|["a", "b", "c"]|prompt|json')] (hope I didn't miss a closer there) as well. I thought to float a poll on SOF on whether people would like it set to true or false by default, but I opted to let people try it out with true as default and let them come back to me if they didn't like it. As for the mouseover, I'm not sure if I understand, do you mean behavior with SPAN and tooltips? I'll look into it if you have more detail.
My stuff for the community:
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
Re: [patch] Input Function improvements(?)
Maybe I missed something about SOF. Is select on focus when you mouse over the radio button or label it will select that option? Or do you mean when using the tab key to change the focus it will select it? I'm sure you now meant the second one, but I didn't get that the first time.
As for json option, will I have to format it like this:
or like this:
because the substitution puts double quotes with in double quotes for the input string. What happens if my json value has a single quote in there?
As for json option, will I have to format it like this:
Code: Select all
[H: input(strformat("jsonVar|%s||JSON",json.set("{}","one",1))]
Code: Select all
[H: input(strformat('jsonVar|%s||JSON',json.set("{}","one",1))]
Code: Select all
[H: input(strformat('jsonVar|%s||JSON',json.set("{}","singleQuote"," ' "))]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: [patch] Input Function improvements(?)
Yes, I meant the latter, tabbing through a radio group will select radio buttons when they receive focus. As for the examples you gave, all went through just fine. There was a missing right parenthesis on each of the samples, however, but other than that, I encountered no problems.
Edit: I forgot to mention, with regard to the posts above, that I'm glad I was able to provide something useful. It was always the intention to provide the tools and get out of the way of all the creative people in the MT community
Edit: I forgot to mention, with regard to the posts above, that I'm glad I was able to provide something useful. It was always the intention to provide the tools and get out of the way of all the creative people in the MT community
My stuff for the community:
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
Re: [patch] Input Function improvements(?)
Very usefull and many thanks. Can you provide some actual useable sample scripts especially on the use of WINDOWS as I d quite get the implementatiom method. But examples of the other methods would be nice as well.
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: [patch] Input Function improvements(?)
I'll see what I can do. I did place some examples on the 1st post. I guess they weren't obvious so I highlighted them in bold. All of them, however, still follow the basic input form of [input(var|value|prompt|options)]. As for Windows, perhaps this Java resource will be more informative .
JSON can manipulate/create both JSON Arrays and Objects, and they display in a PROPS-like display. With A.M.s suggestions, JSON object keys can hold html formatting, though I haven't taken the time to try out how full the HTML capability is. Who knows? Maybe a full frame can find its way into the input window I tried putting some buttons in and they turned out fine; though linking them to macrolinks, I didn't have time to do.
JSON can manipulate/create both JSON Arrays and Objects, and they display in a PROPS-like display. With A.M.s suggestions, JSON object keys can hold html formatting, though I haven't taken the time to try out how full the HTML capability is. Who knows? Maybe a full frame can find its way into the input window I tried putting some buttons in and they turned out fine; though linking them to macrolinks, I didn't have time to do.
My stuff for the community:
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
Re: [patch] Input Function improvements(?)
indeed... I noticed the first two, but missed the one concerning windows. I guess thats good enough, its just to get a feel of the correct syntax. Thanks!Lee wrote:I'll see what I can do. I did place some examples on the 1st post. I guess they weren't obvious so I highlighted them in bold. All of them, however, still follow the basic input form of [input(var|value|prompt|options)]. As for Windows, perhaps this Java resource will be more informative .
JSON can manipulate/create both JSON Arrays and Objects, and they display in a PROPS-like display. With A.M.s suggestions, JSON object keys can hold html formatting, though I haven't taken the time to try out how full the HTML capability is. Who knows? Maybe a full frame can find its way into the input window I tried putting some buttons in and they turned out fine; though linking them to macrolinks, I didn't have time to do.
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: [patch] Input Function improvements(?)
No problem, you're welcome
I uploaded a new version of the patch. I missed something in the last one that I intended to go back to, but didn't; specifically the html label fix and its interaction with radio's SELECTED option. Got that all squared out and should be all good now.
I uploaded a new version of the patch. I missed something in the last one that I intended to go back to, but didn't; specifically the html label fix and its interaction with radio's SELECTED option. Got that all squared out and should be all good now.
My stuff for the community:
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
Re: [patch] Input Function improvements(?)
Sorry by the question, but... how can I install the patch?
Re: [patch] Input Function improvements(?)
You would need to set up the developer environment for MapTool to apply patches to the source code. A tutorial is found here. Depending on your knowledge level, you might want to wait till it gets included on a build to try it out. In case it doesn't make it into the official build, let's wait till the final build is released and I can generate a special version with my patches in it.
My stuff for the community:
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
Re: [patch] Input Function improvements(?)
Thanks Lee, I will make a try to do it for myself. I'm not experimented, but seems a good tutorial. I'm very interested in the implementations of your patch.
Re: [patch] Input Function improvements(?)
Good luck with that. Once you do set it up, applying a patch is easy, just right click on the InputFunction.java (found under src -> net.rptools.maptool.client.functions), select Team and Apply the Patch you downloaded from here.
My stuff for the community:
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in
Donate to the Mote Project
The Mote Project's G+ community
Mote on Facebook
Fully Customizable Calendar Drop-in