Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,294  Location: Tampa, FL Thanks: 28 times Was thanked: 404 time(s) in 349 post(s)
|
Working on this, well it's really just a generic list popup, but can work for text expansion. Download 04.1.8 Installer: https://cdn.strokesplus.net/files/StrokesPlus.net_Setup_0.4.1.8f.exeExample Script - for a Text Expansion item, select Method: Automation, then click the Script tab and put this in there. Code:var items = new List(PopupListItem);
items.Add(new PopupListItem("Item 1", "sp.SendString('Item 1');"));
items.Add(new PopupListItem("Item 2", "sp.SendString('Item 2');"));
items.Add(new PopupListItem("Item 3", "sp.SendString('Item 3');"));
var subItems1 = new List(PopupListItem);
subItems1.Add(new PopupListItem("· Sub Item A", "sp.SendString('Sub Item A');"));
var subSubItems1 = new List(PopupListItem);
subSubItems1.Add(new PopupListItem("· Sub Sub Item X", "sp.SendString('Sub Sub Item X');"));
subItems1.Add(new PopupListItem("· Sub Sub Menu >", "", false, subSubItems1));
items.Add(new PopupListItem("Sub Menu >", "", false, subItems1));
items.Add(new PopupListItem("Selected Item", "sp.SendString('Selected Item');", true));
items.Add(new PopupListItem("LooooooooooooooONg and Tall", `clip.SetText("Reallllllly long block of text that would take a bit long to send each character, so use clipboard instead.");
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_V]);`));
items.Add(new PopupListItem("Close"));
sp.PopupList(items);
You can also specify a font, replace the last line from above with the code below: Code:var font = new Font(new FontFamily("Comic Sans MS"),
22,
host.flags(FontStyle.Bold, FontStyle.Italic),
GraphicsUnit.Pixel
);
sp.PopupList(items, new Point(), font);
The signature for PopupListItem is: sp.PopupList(items, point, font)
- items - List of PopupListItems
- point - (Optional) Point indicating where to show list, omit or pass new Point() to show at caret or mouse cursor
- font - (Optional) Font to use for popup list items
The constructors for PopupListItem are: - new PopupListItem(text) - This would only show an item, but not do anything on selection, other than close the popup
- new PopupListItem(text, script)
- new PopupListItem(text, script, selected) - set selected to true to indicate the item should be the selected one when the popup is shown
- new PopupListItem(text, script, selected, subItems) - subItems is used to create submenus - script parameter is ignored if subItems exist
sp.PopupList supports passing in only a List of PopupListItem (as shown in the script), or including a location for the popup, e.g. sp.PopupList(items, new Point(100,200));. Note that if a point with an X,Y of 0,0 is passed, the code treats that no differently than if the location parameter was not passed in at all. The popup gains focus and supports: - Uses system Menu color for background, Menu Text color for font, and 50% opacity Menu Highlight color for selected item background
- Automatically sizes based on the number of items and text width/height
- Up or Down Arrow to move between items
- Enter or Right Arrow to navigate to sub menu
- Backspace or Left Arrow to navigate to parent menu
- Left click to select or navigate to sub menu
- Right click to navigate to parent menu
- Escape or Delete to close
- Closes automatically when it loses focus
- If no location specified, attempts to place the popup at the text cursor (caret), if the control supports it, otherwise uses mouse location
most standard text controls seem to support the caret location, but for example if you're typing in Chrome, it does not
Try it out and let me know what you think. Edited by user Wednesday, March 10, 2021 5:12:01 AM(UTC)
| Reason: Updated for 0.4.1.8f, updated item list to support JavaScript array notation
|
 1 user thanked Rob for this useful post.
|
|