A couple of little doubts regarding LM.GUI module...

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
Rai López
Posts: 2253
Joined: Sun Aug 08, 2004 1:41 pm
Location: Spain
Contact:

A couple of little doubts regarding LM.GUI module...

Post by Rai López »

Hi, I've been fiddling with the LM.GUI module's elements for some time now and I thought I could (finally) say it has no more secrets to me. Erm... except for a couple ones for which there seems no to be use cases as far as I know, but you might be smarter than me when it comes to deduce the way this kind of things work in spite of that...

    1st has to do with LM_Menu:AddItem(label, shortcut, msg). Has anyone figured out how to take advance of "shortcut" argument? When I saw it there I always imagined you could pass one of this Key codes and then, as long as the container dialog or whatever was in focus, the item will be triggered upon pressing the assigned key, but it doesn't seem to do anything... Another possibility would be you could access KeyEvent from dialogs, but I don't think you are allowed to do that, although I well could be wrong with this assumption since most LM.GUI's classes seem to have some inherited methods from LM_View and I still feel a little lost with this kind of inheritances and relationships matters...

    2nd one is about the LM.GUI Follow Constants. Does anyone know what are they supposed to do? Because for their name I always imagined they should make a widget somehow follows another one should it change it's size (e. g. a changing LM.GUI.DynamicText) or something but, again, it doesn't seem to do anything new in comparison with Control alignment (LM.GUI.ALIGN_BOTTOM, LM.GUI.ALIGN_CENTER, etc) ones, with which share some returned values, BTW.

And, well, that's all... I hope the way it was exposed makes sense :roll:. Thanks in advance for any insights!
...
User avatar
synthsin75
Posts: 10025
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: A couple of little doubts regarding LM.GUI module...

Post by synthsin75 »

LM.GUI.Slider and LM.GUI.ScrollBar use follow codes.


As per the description on mohoscripting.com, "a shortcut key used to trigger the menu command. note that the c binding (correctly) describes this as type "char" but in lua this is a number in the range 0 to 255."
I assume these would use the 8-bit ASCII codes: https://www.thepcmanwebsite.com/ascii-chart.shtml

But I haven't tested that myself.
EDIT: Doesn't seem to work, in my quick test.
User avatar
Rai López
Posts: 2253
Joined: Sun Aug 08, 2004 1:41 pm
Location: Spain
Contact:

Re: A couple of little doubts regarding LM.GUI module...

Post by Rai López »

Oh... I see, so they are supposed to feed widgets allowing an specific argument known as "resizingMode". I thought they could be something more generally applicable to all widgets positioning or something... But good to know about that little piece of info! At least is something, cause for some reason nothing besides the Follow constants appeared against any search I tried on the entire site.

I think I'll play a little with the Sliders even though if it's only to see it in action, although all points now that it will made something similar to LM.GUI.ALIGN_FILL? But sure more specific to work with these two widgets. Regarding LM.GUI.ScrollBar(), well, all we know there is something broken/incomplete with it that prevents any real use, so not sure if it will serve to throw any light, but I may play a little bit with it too (again :roll:).

Well, hopefully that will solve one of the doubts, which is something... Thanks!
...
User avatar
Rai López
Posts: 2253
Joined: Sun Aug 08, 2004 1:41 pm
Location: Spain
Contact:

Re: A couple of little doubts regarding LM.GUI module...

Post by Rai López »

synthsin75 wrote: Sun Jan 29, 2023 9:41 pm LM.GUI.Slider and LM.GUI.ScrollBar use follow codes.
As per the description on mohoscripting.com, "a shortcut key used to trigger the menu command. note that the c binding (correctly) describes this as type "char" but in lua this is a number in the range 0 to 255."
I assume these would use the 8-bit ASCII codes: https://www.thepcmanwebsite.com/ascii-chart.shtml
Hmm... I didn't see that before, thanks too! That's also good to know, but what made me think it could be not working is I tried different random figures and never got a reaction after all, but I may have made more testing... Although I'm enough interested on it, so I'll try whatever I can think in base of this new info too. But if it's not working for you I'm not sure I'm going to be able to get further than that... Maybe it simply has a different functionality than the expected? Although it'd be weird taking into account all the context points to what I think all we believe it should do :roll:
...
User avatar
Rai López
Posts: 2253
Joined: Sun Aug 08, 2004 1:41 pm
Location: Spain
Contact:

Re: A couple of little doubts regarding LM.GUI module...

Post by Rai López »

Well, no luck with the part having to do with Follow Constants, no matter how much I play with them I don't get any response from the widgets... Of course it could be I'm simply not surrounding the Sliders in the expected way or something, but I'm already out of ideas. So I'll pass to play a little more with the Menu shortcuts matter and see if I have a bit more of luck with it...
...
User avatar
Rai López
Posts: 2253
Joined: Sun Aug 08, 2004 1:41 pm
Location: Spain
Contact:

Re: A couple of little doubts regarding LM.GUI module...

Post by Rai López »

Well nothing either... Just a thought, couldn't it be this "shortcut" functionality is exposed there for some reason but it was really part of another kind/flavor of menu widget? I mean, the menu widget we have access from Lua is very different from the main menus we have at the top of the main window after all, e. g. they are presented more as a row of "buttons", they have sub-menus capabilities and, of course, their entries show shortcuts at right. That makes me think that maybe what we have is a "reduced" version of those and, for some reason, the shortcut argument got exposed but it does nothing because it simply shouldn't have been? That's the only explanation I can think off, but of course (and as usual on these matters) it's all wild guess...
...
User avatar
SimplSam
Posts: 1073
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: A couple of little doubts regarding LM.GUI module...

Post by SimplSam »

Just tried the menu shortcut with Moho 5 and ..

Image

Whilst they are now visible, they still don't seem to work - with any combo of Ctrl / Shift / none: a & b

Code: Select all

    self.menuChoice = LM.GUI.Menu("Chooser")
    self.menuChoicePopup = LM.GUI.PopupMenu(110, false)
    self.menuChoicePopup:SetMenu(self.menuChoice)
    self.menuChoice:AddItem("Choice 1", 97, self.CH1)  -- ascii a
    self.menuChoice:AddItem("Choice 2", 66, self.CH2)  -- ascii B
    layout:AddChild(self.menuChoicePopup)
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
User avatar
hayasidist
Posts: 3569
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: A couple of little doubts regarding LM.GUI module...

Post by hayasidist »

I have a feeling that this is another side-effect of the ability to customise shortcuts (can't recall when that was brought in, but a long time ago) and that had the effect of making it virtually impossible for a script to use specific keystrokes because anything could potentially be assigned by a user (private topic 193407 goes into much more detail).
User avatar
Rai López
Posts: 2253
Joined: Sun Aug 08, 2004 1:41 pm
Location: Spain
Contact:

Re: A couple of little doubts regarding LM.GUI module...

Post by Rai López »

SimplSam wrote: Mon Jan 30, 2023 5:54 am Just tried the menu shortcut with Moho 5 and ..
Image

That and Paul's feeling explains a lot, thank you for taking the time of testing it there! At least everything seems to make more sense now...

So probably at some point that feature became a problem for the introduction of another one and they had to choose, I think I can buy and understand that because time/resources are always limited, but the perfect outcome IMO would have been limit scripting menu shortcuts to places where they can't enter in conflict with the ones used by the app, like for example in modal dialog windows (or even in modeless as long as they remain in focus) instead of just killing the feature. Although, on second thoughts, this is still speculation, cause if it was already kind of broken in Moho 5 (😍), I doubt the introduction of customized shortcuts happen before that...

Well, another Lua interface limitation I guess we'll have to live with 🙂
...
Post Reply