[Gambas-user] Action.Register new parameter

Emanuele Sottocorno sotema at ...626...
Sun Sep 4 18:53:37 CEST 2011


Thanks for the reply,
should take 20 minutes to get it work.
Emanuele

> > Hi to all,
> > i can't understand what the new 'old as string' parameter means in
> > Action.Register. I have a class in which i define all actions used for
> > Menus and ToolButtons, than each action is linked to appropriate
> > controls at application start-up. I use this to give the user the chance
> > to select different themes.
> > 
> > ' Gambas class file
> > 
> > 'Classe     : psTheme.Class
> > 'Autore     : Emanuele Sottocorno
> > 'Email      : sotema at ...626...
> > 'Descrizione: Menus and buttons actions
> > 
> > 
> > Public Const ACTION_DEALER_OPEN As String = "DEALER_OPEN"
> > Public Const ACTION_DEALER_CLOSE As String = "DEALER_CLOSE"
> > Public Const ACTION_DEALER_EDIT As String = "DEALER_EDIT"
> > Public Const ACTION_USER_ADD As String = "USER_ADD"
> > Public Const ACTION_USER_EDIT As String = "USER_EDIT"
> > ...
> > ...
> > Static Public Sub ActionConfigure()
> >   With Action[ACTION_DEALER_OPEN]
> >     .Picture = psTheme.GetIcon(psTheme.DEALER_OPEN)
> >   End With
> >   With Action[ACTION_DEALER_EDIT]
> >     .Picture = psTheme.GetIcon(psTheme.DEALER_EDIT)
> >   End With
> >   With Action[ACTION_USER_ADD]
> >     .Picture = psTheme.GetIcon(psTheme.USER_ADD)
> >   End With
> >   With Action[ACTION_USER_EDIT]
> >     .Picture = psTheme.GetIcon(psTheme.USER_EDIT)
> >   End With
> > ...
> > End
> > Ok, the right picture is asoociated to controls.
> > 
> > Since rev 4072 i used the following to register the actions:
> > ' Gambas class file
> > 
> > 'Classe     : Fmain.Class
> > 'Autore     : Emanuele Sottocorno
> > 'Email      : sotema at ...626...
> > 'Descrizione: Application Main Window
> > 
> > 
> > Event MoveMenu(obj As Object)
> > Event MainMenu(obj As Object)
> > Event FormEvent(hForm As Form)
> > 
> > 
> > 
> > Public Sub _new()
> >   Me.Icon = pneusoft.GetIconFile(psTheme.PNEUSOFT_ICON_64)
> > ' Configure Actions for Menu an buttons
> > ' Menu Actions:
> >   Action.Register(mnuAziendaApri,psAction.ACTION_DEALER_OPEN)
> >   Action.Register(mnuAziendaModifica,psAction.ACTION_DEALER_EDIT)
> >   Action.Register(mnuUtenzaAdd,psAction.ACTION_USER_ADD)
> >   Action.Register(mnuUtenzaEdit, psAction.ACTION_USER_EDIT)
> > ...
> > End
> > 
> > Now, starting with rev 7073 this becomes invalid due the 'old as string'
> > parameter .
> > 
> > Modifing the lines like (no action associated to objects in the IDE):
> > 
> > Public Sub _new()
> >   Me.Icon = pneusoft.GetIconFile(psTheme.PNEUSOFT_ICON_64)
> > ' Configure Actions for Menu an buttons
> > ' Menu Actions:
> >   Action.Register(mnuAziendaApri, "", psAction.ACTION_DEALER_OPEN)
> >   Action.Register(mnuAziendaModifica, "", psAction.ACTION_DEALER_EDIT)
> >   Action.Register(mnuUtenzaAdd, "", psAction.ACTION_USER_ADD)
> >   Action.Register(mnuUtenzaEdit, "", psAction.ACTION_USER_EDIT)
> > ...
> > End
> > 
> > 
> > Public Sub menuevent_click()
> >   Raise MainMenu(Last)
> > End
> > 
> > when i click an object it raise a NULL string action. I mean that
> > looking at LAST there is a void string in Action Field property.
> > 
> > Executing the cycle:
> > Dim o As Object
> >   For Each o In Action[psAction.ACTION_USER_EDIT].Controls
> >     Debug o.Name
> >   Next
> > 
> > the right object name are printed in console.
> > 
> > How can i do that now?
> > Thanks,
> > Emanuele
> > 
> 
> Sorry, Action.Register() was never intended to be used directly. It even has 
> been renamed recently to become an hidden symbol.
> 
> To associate an action with a control, you have to define the Action property 
> of that control. For example, instead of:
> 
>   Action.Register(mnuAziendaApri, "", psAction.ACTION_DEALER_OPEN)
> 
> You must do:
> 
>   mnuAziendaApri.Action = psAction.ACTION_DEALER_OPEN
> 
> And to know when an action is activated, you must define the "Action_Activate" 
> event handler in your form. That event handler takes one argument which is the 
> action that has been activated.
> 
> And actions should be defined directly in the IDE. That way, you have 
> automatic toolbar configuration (if you use the gb.form.mdi component).
> 
> Regards,
> 
> -- 
> Beno?t Minisini






More information about the User mailing list