Figured out a better way to do this. Originally, I was thinking about how you could use Macros and what not to reduce your clicks. It doesn't seem there is an innate way in the sBasic programming/commands to just make an event occur, like to click a button or to select a choice in a layout element as if a user clicked it. However, I think there is another way that might work for you.
This form has three elements. A "Name" text LE (purely for example and saving test records), a "Selection_List" List Box LE, and a "Select" Command Button LE.
The "Selection_List" List Box LE has special formatting in that it's Look is changed to an "Up Box" and it's Label is set to blank, and it's Selection Layer is 2 (or any Layer that's higher than the other LEs that you want it to hover over). The other two LEs have their default formatting.
This is what it looks like:
https://imgur.com/a/F8X7YGl
There are a few different event programming snippets to add for this form. Here they are below:
Selection_List :: On Form Entry
Visibility(Selection_List, 0)
PopulateListElement(Selection_List, "")
//Sets the element to invisible and makes sure that it's populated as blank by default.
Selection_List :: On Form Exit
PopulateListElement(Selection_List, "")
//So that your form doesn't ask if you if you want to save a record
//that's been changed or not. And since you aren't using this list
//to actually save data but to rather make a selection you don't
//ever need a a selection to stay permaneant.
Selection_List :: On Element Immediate Change
var vListItem as String
var vOpenDoc as Int
vListItem = Selection_List
If vListItem > "" Then
{
vOpenDoc = @ASynchShell("C:\Sesame2\Docs\" + vListItem)
}
Visibility(Selection_List, 0)
PopulateListElement(Selection_List, "")
//Any time you select a different item in the list it automatically sets that
//List Box element as whatever selection you made. Anytime this changes from
//blank it will run your code, which in this case, means it will open the file
//path. Immediately after running that bit of code it will reset the element to
//invisible and repopulate it as blank. Thus, acting similar to a regular popup
//choice list. This will only work in update mode as you're not actually changing
//anything in Search Mode, and I couldn't see what it's use would be in Add mode
//either..
Selection_List :: On Retrieve Spec Open
Visibility(Selection_List, 0)
PopulateListElement(Selection_List, "")
//Makes sure the element is invisible and populated as blank in Search Mode.
Select :: On Element Entry
var directoryList as String
If @Mode() = 1
{
Visibility(Selection_List, 1)
directoryList = @LocalListDirectory("C:\Sesame2\Docs\")
PopulateListElement(Selection_List, directoryList)
}
//Makes the selection list visible and finally populates it with the
//directory you want. Thus allowing you to make your selection choice.
//It's mportant to note that this button will only be ReadOnly(Writeable)
//in Update Mode.
Select :: On Form Entry
If @Mode() = 1
{
ReadOnly(Select, 0)
}
Else
{
ReadOnly(Select, 1)
}
//Makes sure the "Select" button element is ReadOnly(Writeable) in Update Mode
//and ReadOnly(Grayed Out) in Add Mode.
Select :: On Retrieve Spec Open
ReadOnly(Select, 1)
//Makes sure the "Select" button element is only ReadOnly(Grayed Out) in Search Mode.
This is what it looks like in Search or Add Mode:
https://imgur.com/a/j1vwQs7This is what it looks like when you click the Select Button in Update Mode:
https://imgur.com/a/TVCkKOH
As you can see it solves all of your problems you originally had. You can place the List Box LE wherever you want in your form, even if it overlaps other elements, because if you set a higher selection layer it will hover over the other elements. It allows you to set any style and size of font you want for your text items. And it also innately and automatically has scroll bars. It also only requires two-clicks to open the document of your choice. The only downside that I've found is that I couldn't get it to show the selection I made for a a second or two before it actually opens the document. So, you will click an item but you will not actually see a visual signifier. You will simply see the document open and the list disappear. I tried using Loiter(1000) but it wouldn't work. As long as the other event programming was going to run it wouldn't show the List Box as having a selection ("blue highlighting of the text"). Anyways, I'm sure there's a workaround to make that work or to give some kind of visual or audio signifier that an item has been selected but at least this will make your code work for now.