Difference between revisions of "Method create"
From Ribbon Commander Documentation
(→C#) |
(→Parameters) |
||
(12 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
== Description == | == Description == | ||
− | Static factory method for [[rxCustomUI]] objects | + | Static factory method for [[rxCustomUI]] objects. |
== Parameters == | == Parameters == | ||
{{FuncTableBegin}} | {{FuncTableBegin}} | ||
{{FuncTableEntry | name=contextId | type=string | value=null | desc=The context's unique string identifier}} | {{FuncTableEntry | name=contextId | type=string | value=null | desc=The context's unique string identifier}} | ||
− | {{FuncTableEntry | name=description | type=string | value=' | + | {{FuncTableEntry | name=description | type=string | value='Ribbon Commander' | desc=The context's description}} |
{{FuncTableEntry | name=dispatchScope | type=[[rxDispatchScope]] | value=DispatchScope_local | desc=(VBA-specific) The context's dispatch mode}} | {{FuncTableEntry | name=dispatchScope | type=[[rxDispatchScope]] | value=DispatchScope_local | desc=(VBA-specific) The context's dispatch mode}} | ||
{{FuncTableEntry | name=customUIMode | type=[[rxCustomUIMode]] | value=CustomUIMode_dynamic | desc=The context's mode}} | {{FuncTableEntry | name=customUIMode | type=[[rxCustomUIMode]] | value=CustomUIMode_dynamic | desc=The context's mode}} | ||
Line 14: | Line 11: | ||
== Remarks == | == Remarks == | ||
+ | # A new context is created if it doesn't already exist. If it does exist, the newly created [[rxCustomUI]] object joins the existing context. | ||
+ | # Parameter ''description'' only takes effect when a new context is created. | ||
+ | # Parameter ''customUIMode'' should be set to CustomUIMode_dynamic (the default value) for smoother UI rendering. | ||
+ | # (VBA-specific) Whenever an [[rxCustomUI]] with [[rxDispatchScope | global dispatch]] is created it is added the [[Method globalContexts | 'Global Contexts']] collection and doesn't get destroyed until explicitly removed from that collection (i.e. it doesn't get destroyed when ''Stop'' is pressed in the VBA editor or when unhandled exceptions are encountered). | ||
+ | # (VBA-specific) Whenever an [[rxCustomUI]] with [[rxDispatchScope | local dispatch]] is created, the lifetime of the context is tied to the lifetime of the [[rxCustomUI]] (or [[rxCustomUI]]'s) in the context. i.e. When the last [[rxCustomUI]] of the context is destroyed, the context is also destroyed. | ||
== Examples == | == Examples == | ||
Line 20: | Line 22: | ||
<syntaxhighlight lang="vb" line> | <syntaxhighlight lang="vb" line> | ||
' Create an rxCustomUI with global dispatch | ' Create an rxCustomUI with global dispatch | ||
+ | ' A new context is created at this point | ||
Dim myCustomUI As rxCustomUI | Dim myCustomUI As rxCustomUI | ||
Set myCustomUI = rxCustomUI.create("my_sample_context", "My Global Context", DispatchScope_global) | Set myCustomUI = rxCustomUI.create("my_sample_context", "My Global Context", DispatchScope_global) | ||
' Create a second rxCustomUI in the same context but with local dispatch | ' Create a second rxCustomUI in the same context but with local dispatch | ||
+ | ' The specified context already exists, so the created rxCustomUI joins the existing context | ||
Dim myCustomUI2 as rxCustomUI | Dim myCustomUI2 as rxCustomUI | ||
Set myCustomUI2 = rxCustomUI.create("my_sample_context", "My Global Context", DispatchScope_local) | Set myCustomUI2 = rxCustomUI.create("my_sample_context", "My Global Context", DispatchScope_local) | ||
' NOTE: Both objects now have access to the same state | ' NOTE: Both objects now have access to the same state | ||
− | ' NOTE2: Notice that the dispatch scope is a property of rxCustomUI; not its context. i.e. | + | ' NOTE2: Notice that the dispatch scope is a property of rxCustomUI; not its context. i.e. rxCustomUIs |
' with different dispatch scopes belong to the same context above. | ' with different dispatch scopes belong to the same context above. | ||
_ | _ | ||
Line 35: | Line 39: | ||
=== C# === | === C# === | ||
<syntaxhighlight lang="csharp" line> | <syntaxhighlight lang="csharp" line> | ||
+ | // Create a new rxCustomUI in context 'cs_ribbon_context' | ||
+ | // The context doesn't exist at this point so it will get created | ||
rxCustomUI myCustomUI = rxCustomUI.create("cs_ribbon_context", "C# Ribbon"); | rxCustomUI myCustomUI = rxCustomUI.create("cs_ribbon_context", "C# Ribbon"); | ||
+ | |||
+ | // Create another rxCustomUI in context 'cs_ribbon_context' | ||
+ | // The context already exitsts at this point, so the new rxCustomUI will | ||
+ | // just join that context | ||
+ | rxCustomUI myCustomUI2 = rxCustomUI.create("cs_ribbon_context", "C# Ribbon"); | ||
+ | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== VB.NET === | === VB.NET === | ||
<syntaxhighlight lang="vb" line> | <syntaxhighlight lang="vb" line> | ||
+ | ' Create a new rxCustomUI in context 'vb_ribbon_context' | ||
+ | ' The context doesn't exist at this point so it will get created | ||
+ | Dim myCustomUI As rxCustomUI = rxCustomUI.create("vb_ribbon_context", "VB.NET context") | ||
+ | |||
+ | ' Create another context in context 'vb_ribbon_context' | ||
+ | ' The context already exists at this point, so the new rxCustomUI will | ||
+ | ' just join that context | ||
+ | Dim myCustomUI2 As rxCustomUI = rxCustomUI.create("vb_ribbon_context", "VB.NET context") | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 10:36, 21 October 2013
Description
Static factory method for rxCustomUI objects.
Parameters
Parameter Name
|
Parameter Type
|
Default Value
|
Description
|
contextId | string | null | The context's unique string identifier |
description | string | 'Ribbon Commander' | The context's description |
dispatchScope | rxDispatchScope | DispatchScope_local | (VBA-specific) The context's dispatch mode |
customUIMode | rxCustomUIMode | CustomUIMode_dynamic | The context's mode |
Remarks
- A new context is created if it doesn't already exist. If it does exist, the newly created rxCustomUI object joins the existing context.
- Parameter description only takes effect when a new context is created.
- Parameter customUIMode should be set to CustomUIMode_dynamic (the default value) for smoother UI rendering.
- (VBA-specific) Whenever an rxCustomUI with global dispatch is created it is added the 'Global Contexts' collection and doesn't get destroyed until explicitly removed from that collection (i.e. it doesn't get destroyed when Stop is pressed in the VBA editor or when unhandled exceptions are encountered).
- (VBA-specific) Whenever an rxCustomUI with local dispatch is created, the lifetime of the context is tied to the lifetime of the rxCustomUI (or rxCustomUI's) in the context. i.e. When the last rxCustomUI of the context is destroyed, the context is also destroyed.
Examples
VBA
' Create an rxCustomUI with global dispatch
' A new context is created at this point
Dim myCustomUI As rxCustomUI
Set myCustomUI = rxCustomUI.create("my_sample_context", "My Global Context", DispatchScope_global)
' Create a second rxCustomUI in the same context but with local dispatch
' The specified context already exists, so the created rxCustomUI joins the existing context
Dim myCustomUI2 as rxCustomUI
Set myCustomUI2 = rxCustomUI.create("my_sample_context", "My Global Context", DispatchScope_local)
' NOTE: Both objects now have access to the same state
' NOTE2: Notice that the dispatch scope is a property of rxCustomUI; not its context. i.e. rxCustomUIs
' with different dispatch scopes belong to the same context above.
_
C#
// Create a new rxCustomUI in context 'cs_ribbon_context'
// The context doesn't exist at this point so it will get created
rxCustomUI myCustomUI = rxCustomUI.create("cs_ribbon_context", "C# Ribbon");
// Create another rxCustomUI in context 'cs_ribbon_context'
// The context already exitsts at this point, so the new rxCustomUI will
// just join that context
rxCustomUI myCustomUI2 = rxCustomUI.create("cs_ribbon_context", "C# Ribbon");
VB.NET
' Create a new rxCustomUI in context 'vb_ribbon_context'
' The context doesn't exist at this point so it will get created
Dim myCustomUI As rxCustomUI = rxCustomUI.create("vb_ribbon_context", "VB.NET context")
' Create another context in context 'vb_ribbon_context'
' The context already exists at this point, so the new rxCustomUI will
' just join that context
Dim myCustomUI2 As rxCustomUI = rxCustomUI.create("vb_ribbon_context", "VB.NET context")