[Gambas-user] Creating Actions at runtime

Me adamnt42 at gmail.com
Sat Sep 29 03:41:32 CEST 2018


On Thu, 27 Sep 2018 14:48:47 +0200
Benoît Minisini <g4mba5 at gmail.com> wrote:

> Le 27/09/2018 à 05:33, Me a écrit :
> > On Fri, 21 Sep 2018 09:49:27 +0200
> > Gianluigi <bagonergi at gmail.com> wrote:
> > 
> >>   Thanks Gianluigi. (I missed your post somehow the other day).
> > 
> > Well, it looks like what I wanted to do is not possible.
> > 
> > Some observations. (Mainly for my own interest as I will probably need to refer to this later in time.)
> > 1) The Action.Configure() function uses the form defined in the gb.gui.mdi component.
> > Which is interesting! At least I was able to redefine the size of the pop-up to something more
> > reasonable.
> > 1a) That shortcut editor only looks at the files in the .action sub-directory (or the executable archive
> >   version thereof) of the active project to build its' list of "editable" actions. In addition, it will only add
> > actions that have a defined shortcut already.
> > This then, means that all user configurable shortcuts must be defined statically in the project design as
> > that is the only way they will get into the .action files.
> > 2) Really bewildering! Creating a menu item at runtime, works. Further, the Action and Shortcut defined
> > in the code operate as expected. I can evidence this by creating a couple of menus in the code, one of
> > which hides or shows the other using the Action defined for the other. However, these items do not
> > appear in the Action,List array?
> > I thought I might be able to use the Action.List array and build my own shortcut editor. No joy.
> > 
> > 
> 
> Maybe creating an Action.Add() method is the solution?
> 
> Better would be doing that automatically, when the control is created.
> 
> But it is harder, because how to know that the newly created control was 
> not already part of the actions defined in the ".action" directory?
> 
> -- 
> Benoît Minisini
> 
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----

I don't think that the latter would work as the code defining the control action could 
be anywhere. Not necessarily when and where the control is created?

An explicit Action.Add() would be beneficial,

The thing I don't understand is why the new action doesn't appear in Action.List but the
Action works? In other words, where does the new action string get registered? Is it 
somewhere down low in the UI library itself? I have searched myself silly through the
gambas source code but I cannot find it.

regards
Bruce
--
adamant42 at gmail.com


More information about the User mailing list