StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Sherif Aliti  
#1 Posted : Thursday, February 25, 2021 11:05:49 AM(UTC)
Sherif Aliti

Rank: Member

Reputation:

Groups: Approved
Joined: 2/16/2021(UTC)
Posts: 13
Albania
Location: Fier

Thanks: 11 times
Text expansion is gr8 future, but with the combo will be fulfilled

ex:If we write short word wbr and hit space it will write with best regards but let's suppose we want more words, sentences, or whatever with 1 word
So when we write WBR we can get COMBO list so with enter or mouse click will past at the cursor position.

Its hard to make it but it will complete text expansion sector.

example
Example
Rob  
#2 Posted : Monday, March 8, 2021 5:42:24 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 912
United States
Location: Tampa, FL

Thanks: 21 times
Was thanked: 255 time(s) in 222 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.exe

Example 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

thanks 1 user thanked Rob for this useful post.
Sherif Aliti on 3/8/2021(UTC)
Sherif Aliti  
#3 Posted : Monday, March 8, 2021 10:37:21 AM(UTC)
Sherif Aliti

Rank: Member

Reputation:

Groups: Approved
Joined: 2/16/2021(UTC)
Posts: 13
Albania
Location: Fier

Thanks: 11 times
Work gr8, just is there a possibility for submenus?
ex:

Folder 1 > colors > text1
text2
text3

Folder 2 > stokes > text1
text2
text3

So separated into directories.


each of those dir has text inside

Regards

Edited by moderator Tuesday, March 9, 2021 2:22:22 PM(UTC)  | Reason: Removed quoted block, for thread readability

Rob  
#4 Posted : Monday, March 8, 2021 3:27:25 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 912
United States
Location: Tampa, FL

Thanks: 21 times
Was thanked: 255 time(s) in 222 post(s)
Updated post with new download (0.4.1.8c) and script demonstrating nested submenus.

It's not a fancy implementation (folder icons, etc) as I wanted this to be very lightweight and efficient, so it's only using a simple ListBox.

Which is why I'm using text elements in the item text to provide visual cues in my example (> for submenus, · to signal you're in a submenu).
thanks 1 user thanked Rob for this useful post.
Sherif Aliti on 3/10/2021(UTC)
Rob  
#5 Posted : Tuesday, March 9, 2021 2:21:46 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 912
United States
Location: Tampa, FL

Thanks: 21 times
Was thanked: 255 time(s) in 222 post(s)
Updated post again, new download (0.4.1.8d) and new optional parameter to specify the font.
thanks 1 user thanked Rob for this useful post.
Sherif Aliti on 3/10/2021(UTC)
Rob  
#6 Posted : Tuesday, March 9, 2021 6:08:48 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 912
United States
Location: Tampa, FL

Thanks: 21 times
Was thanked: 255 time(s) in 222 post(s)
Another installer link update (0.4.1.8e), added Delete to close like Escape (closer to arrow keys), adjusted selected item background color to 50% system Menu Highlight color.
Updated original post text to include these details.
thanks 1 user thanked Rob for this useful post.
Sherif Aliti on 3/10/2021(UTC)
Rob  
#7 Posted : Wednesday, March 10, 2021 5:11:26 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 912
United States
Location: Tampa, FL

Thanks: 21 times
Was thanked: 255 time(s) in 222 post(s)
Another update, 0.4.1.8f.

https://cdn.strokesplus.net/files/StrokesPlus.net_Setup_0.4.1.8f.exe

Updated to support JavaScript array in place of List<PopupListItem> - the original version will still work fine, or the new style below.
I feel this might be a little easier to read and write - the number of parameters and rules all remain the same, this is just a different notation style.
Code:
var items =  
[
    ["Item 1", "sp.SendString('Item 1');"],
    ["Item 2", "sp.SendString('Item 2');"],
    ["Sub Menu >",  "", false, [
          ["· Sub Item A", "sp.SendString('Sub Item A');"],
          ["· Sub Sub Menu >", "", false, [ 
                ["· Sub Sub Item X", "sp.SendString('Sub Sub Item X');"]
          ]]
    ]],
    ["Selected Item", "sp.SendString('Selected Item');", true],
    ["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]);`
    ],
    ["Close"]
]

sp.PopupList(items);
thanks 1 user thanked Rob for this useful post.
Sherif Aliti on 3/10/2021(UTC)
Sherif Aliti  
#8 Posted : Wednesday, March 10, 2021 12:00:34 PM(UTC)
Sherif Aliti

Rank: Member

Reputation:

Groups: Approved
Joined: 2/16/2021(UTC)
Posts: 13
Albania
Location: Fier

Thanks: 11 times
Originally Posted by: Rob Go to Quoted Post
Another update, 0.4.1.8f.

https://cdn.strokesplus.net/files/StrokesPlus.net_Setup_0.4.1.8f.exe

Updated to support JavaScript array in place of List<PopupListItem> - the original version will still work fine, or the new style below.
I feel this might be a little easier to read and write - the number of parameters and rules all remain the same, this is just a different notation style.
Code:
var items =  
[
    ["Item 1", "sp.SendString('Item 1');"],
    ["Item 2", "sp.SendString('Item 2');"],
    ["Sub Menu >",  "", false, [
          ["· Sub Item A", "sp.SendString('Sub Item A');"],
          ["· Sub Sub Menu >", "", false, [ 
                ["· Sub Sub Item X", "sp.SendString('Sub Sub Item X');"]
          ]]
    ]],
    ["Selected Item", "sp.SendString('Selected Item');", true],
    ["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]);`
    ],
    ["Close"]
]

sp.PopupList(items);


Work g8, need a bit of effort and java knowing but it will do job
If in near future can be implemented some easy method will be gr8

Regards

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.