Method make delegate

From Ribbon Commander Documentation
Revision as of 17:00, 14 March 2013 by Rxdff15551 bb53 (Talk | contribs) (VBA)

Jump to: navigation, search

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

  1. (VBA-specific) If the rxCustomUI object has global dispatch scope, the target function needs to be a global member of a standard VBA module
  2. Otherwise the target function needs to be a public method of the object used as the rxCustomUI's dispatch object.
  3. (.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

  1. Public Sub MakeDelegateTest()
  2.  
  3.     ' Create a new rxCustomUI with global dispatch scope
  4.     Dim myCustomUI As rxCustomUI
  5.     Set myCustomUI = rxCustomUI.Create("my_custom_context", , DispatchScope_global)
  6.  
  7.     With myCustomUI
  8.         ' Clear old state
  9.         .Clear
  10.  
  11.         ' Add new tab and label it 'My Tab'
  12.         With .ribbon.tabs.Add(New rxTab)
  13.             .Label = "My Tab"
  14.             ' Add new group and label it 'My Group'
  15.             With .groups.Add(New rxGroup)
  16.  
  17.                 ' Add a new button and label it 'Click Me!'
  18.                 Dim myButton As rxButton
  19.                 Set myButton = .Buttons.Add(New rxButton)
  20.  
  21.                 myButton.Label = "Click Me!"
  22.  
  23.                 ' Add a delegate that dispatches to a function with name 'MyCallbackFunc'
  24.                 myButton.OnAction = myCustomUI.make_delegate("MyCallbackFunc")
  25.  
  26.             End With
  27.  
  28.         End With
  29.  
  30.         'Render the UI
  31.         .Refresh
  32.  
  33.     End With
  34.  
  35. End Sub
  36.  
  37. ' The callback stub
  38. Public Sub MyCallbackFunc(ByVal control As DynamicRibbonX.IRibbonControl)
  39.     MsgBox "Button clicked!"
  40. End Sub

See also: Creating our first button in VBA

C#

  1.  

VB.NET

  1.  

C++

  1.