Method make delegate
From Ribbon Commander Documentation
Contents
Description
Creates a new rxDelegate object associated to a callback function and owned by the rxCustomUI instance.
Parameters
rxCustomUI.make_delegate(string) -> rxDelegate
Parameter Name
|
Parameter Type
|
Default Value
|
Description
|
methodName | string | [none] | The name of the target callback function |
return | rxDelegate | [none] | The newly created rxDelegate |
rxCustomUI.make_delegate(Delegate) -> rxDelegate
Parameter Name
|
Parameter Type
|
Default Value
|
Description
|
callbackDelegate | Delegate | [none] | An instance of a .NET delegate used to dispatch the callback |
return | rxDelegate | [none] | The newly created rxDelegate |
Remarks
- (VBA-specific) If the rxCustomUI object has global dispatch scope, the target function needs to be a global member of a standard VBA module
- Otherwise the target function needs to be a public method of the object used as the rxCustomUI's dispatch object.
- (.NET-specific) By using the second method override, Native .NET delegates can be used to instantiate rxDelegate objects. There is a [control name]Delegates class for every Dynamic RibbonX control in namespace LogismiX.DynamicRibbonX.Core that specifies the callback signature of every callback (see Examples).
Examples
VBA
Public Sub MakeDelegateTest()
' Create a new rxCustomUI with global dispatch scope
Dim myCustomUI As rxCustomUI
Set myCustomUI = rxCustomUI.Create("my_custom_context", , DispatchScope_global)
With myCustomUI
' Clear old state
.Clear
' Add new tab and label it 'My Tab'
With .ribbon.tabs.Add(New rxTab)
.Label = "My Tab"
' Add new group and label it 'My Group'
With .groups.Add(New rxGroup)
' Add a new button and label it 'Click Me!'
Dim myButton As rxButton
Set myButton = .Buttons.Add(New rxButton)
myButton.Label = "Click Me!"
' Add a delegate that dispatches to a function with name 'MyCallbackFunc'
myButton.OnAction = myCustomUI.make_delegate("MyCallbackFunc")
End With
End With
'Render the UI
.Refresh
End With
End Sub
' The callback stub
Public Sub MyCallbackFunc(ByVal control As DynamicRibbonX.IRibbonControl)
MsgBox "Button clicked!"
End Sub
See also: Creating our first button in VBA