Difference between revisions of "IC Python API:RLPy REventHandler"

From Reallusion Wiki!
Jump to: navigation, search
(Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Modules|Modules}} ==Detailed Description== This class is used to register callbacks for system events. <syntaxhighlight lang="Python">...")
 
m
 
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
==Detailed Description==
+
{{last_modified}}
This class is used to register callbacks for system events.
+
 
<syntaxhighlight lang="Python">
+
== Description ==
 +
 
 +
Inside iClone, events are responsible for communicating various types of status changes. For recieving different types of events, one would need to inherit from the  [[IC_Python_API:RLPy_REventCallback|REventCallback]] base class, and use [[#RegisterCallback ( pCallback )|RegisterCallback]] to register it. Then, one is able to execute relevant commands for the corresponding events, i.e. refreshing user interfaces, etc. 
 +
 
 +
See Also: [[IC_Python_API:RLPy_REventCallback|REventCallback]]
 +
 
 +
== Member Functions ==
 +
 
 +
=== RegisterCallback ( pCallback ) ===
 +
 
 +
Register an event callback and return an id which can be used when UnregisterCallback is called.
 +
 
 +
See Also: [[#UnregisterCallback ( uId )|UnregisterCallback]]
 +
 
 +
==== Parameters ====
 +
:'''pCallback''' [IN] The callback event - [[IC_Python_API:RLPy_REventCallback|REventCallback]]
 +
 
 +
==== Returns ====
 +
:The newly registered callback id - integer
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 
class MyEventCallback(RLPy.REventCallback):
 
class MyEventCallback(RLPy.REventCallback):
def __init__(self):
+
  def __init__(self):
   RLPy.REventCallback.__init__(self)
+
      RLPy.REventCallback.__init__(self)
def OnObjectSelectionChanged(self):
+
  def OnObjectSelectionChanged(self):
   print("OnObjectSelectionChanged")
+
      print("OnObjectSelectionChanged")
  def OnFileLoaded(self, file_type):
+
   print("OnFileLoaded")
+
  def OnObjectDeleted(self):
+
   print("OnObjectDeleted")
+
+
 
# register event
 
# register event
 
event_callback = MyEventCallback()
 
event_callback = MyEventCallback()
 
id = RLPy.REventHandler.RegisterCallback(event_callback)
 
id = RLPy.REventHandler.RegisterCallback(event_callback)
...
 
status = RLPy.REventHandler.UnregisterCallback(id) #return RStatus
 
 
</syntaxhighlight>
 
</syntaxhighlight>
==Member Functions==
 
===RegisterCallback===
 
<syntaxhighlight lang="Python">
 
RLPy.REventHandler.RegisterCallback ( pCallback )
 
</syntaxhighlight>
 
Register event listener callback.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''pCallback''' [IN] REventCallback - RLPy.REventCallback
+
=== UnregisterCallback ( uId ) ===
</div>
+
====Returns====
+
<div style="margin-left: 2em;">Callback id - int
+
</div>
+
-----
+
===UnregisterCallback===
+
<syntaxhighlight lang="Python">
+
RLPy.REventHandler.UnregisterCallback ( uId )
+
</syntaxhighlight>
+
Remove callback with id.
+
====Parameters====
+
<div style="margin-left: 2em;">
+
  
'''uId''' [IN] callback id - int
+
Unregister a callback event by id. When successful, the EventCallback will be removed and the system will no longer receive the event.  If the id can not be found, then return '''RLPy.RStatus.Failure'''.
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
See Also: [[#UnregisterCallbacks ( kIds )|UnregisterCallbacks]]
  
'''RLPy.RStatus.Failure''' Fail
+
==== Parameters ====
</div>
+
:'''uId''' [IN] Id - integer
-----
+
 
===UnregisterCallbacks===
+
==== Returns ====
<syntaxhighlight lang="Python">
+
:Success - RLPy.RStatus.Success
RLPy.REventHandler.UnregisterCallbacks ( kIds )
+
:Failure - RLPy.RStatus.Failure
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
class MyEventCallback(RLPy.REventCallback):
 +
  def __init__(self):
 +
      RLPy.REventCallback.__init__(self)
 +
  def OnObjectSelectionChanged(self):
 +
      print("OnObjectSelectionChanged")
 +
 +
event_callback = MyEventCallback()
 +
id = RLPy.REventHandler.RegisterCallback(event_callback)
 +
# do something
 +
status = RLPy.REventHandler.UnregisterCallback(id)
 
</syntaxhighlight>
 
</syntaxhighlight>
Remove callbacks with ids.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kIds''' [IN] callback ids - int
+
=== UnregisterCallbacks ( kIds ) ===
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
Unregister several callback events at once. If an id in the list can not be found, then return '''RLPy.RStatus.Failure'''.
  
'''RLPy.RStatus.Failure''' Fail
+
See Also: [[#UnregisterCallback ( uId )|UnregisterCallback]]
</div>
+
 
-----
+
==== Parameters ====
===SetListener===
+
:'''kIds''' [IN] Event callback ids - List
<syntaxhighlight lang="Python">
+
 
RLPy.REventHandler.SetListener ( pListener )
+
==== Return ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
class MyEventCallback(RLPy.REventCallback):
 +
  def __init__(self):
 +
      RLPy.REventCallback.__init__(self)
 +
  def OnObjectSelectionChanged(self):
 +
      print("OnObjectSelectionChanged")
 +
 +
event_callback = MyEventCallback()
 +
id = RLPy.REventHandler.RegisterCallback(event_callback)
 +
# do something
 +
status = RLPy.REventHandler.UnregisterCallbacks([id])
 
</syntaxhighlight>
 
</syntaxhighlight>
Set RIEventListener instance <span style="background:#ffcccc">[internal]</span>.
 

Latest revision as of 01:39, 29 April 2020

Main article: Modules.
Last modified: 04/29/2020

Description

Inside iClone, events are responsible for communicating various types of status changes. For recieving different types of events, one would need to inherit from the REventCallback base class, and use RegisterCallback to register it. Then, one is able to execute relevant commands for the corresponding events, i.e. refreshing user interfaces, etc.

See Also: REventCallback

Member Functions

RegisterCallback ( pCallback )

Register an event callback and return an id which can be used when UnregisterCallback is called.

See Also: UnregisterCallback

Parameters

pCallback [IN] The callback event - REventCallback

Returns

The newly registered callback id - integer
1 class MyEventCallback(RLPy.REventCallback):
2    def __init__(self):
3        RLPy.REventCallback.__init__(self)
4    def OnObjectSelectionChanged(self):
5        print("OnObjectSelectionChanged")
6  
7 # register event
8 event_callback = MyEventCallback()
9 id = RLPy.REventHandler.RegisterCallback(event_callback)

UnregisterCallback ( uId )

Unregister a callback event by id. When successful, the EventCallback will be removed and the system will no longer receive the event. If the id can not be found, then return RLPy.RStatus.Failure.

See Also: UnregisterCallbacks

Parameters

uId [IN] Id - integer

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
 1 class MyEventCallback(RLPy.REventCallback):
 2    def __init__(self):
 3        RLPy.REventCallback.__init__(self)
 4    def OnObjectSelectionChanged(self):
 5        print("OnObjectSelectionChanged")
 6  
 7 event_callback = MyEventCallback()
 8 id = RLPy.REventHandler.RegisterCallback(event_callback)
 9 # do something
10 status = RLPy.REventHandler.UnregisterCallback(id)

UnregisterCallbacks ( kIds )

Unregister several callback events at once. If an id in the list can not be found, then return RLPy.RStatus.Failure.

See Also: UnregisterCallback

Parameters

kIds [IN] Event callback ids - List

Return

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
 1 class MyEventCallback(RLPy.REventCallback):
 2    def __init__(self):
 3        RLPy.REventCallback.__init__(self)
 4    def OnObjectSelectionChanged(self):
 5        print("OnObjectSelectionChanged")
 6  
 7 event_callback = MyEventCallback()
 8 id = RLPy.REventHandler.RegisterCallback(event_callback)
 9 # do something
10 status = RLPy.REventHandler.UnregisterCallbacks([id])