@@ -122,6 +122,7 @@ import {
122
122
CALL_ACTION_ICON ,
123
123
CALL_NATIVE_ACTION_ICON ,
124
124
CLIPBOARD_WRITE_ICON ,
125
+ FOCUS_WIDGET_ICON ,
125
126
LANGUAGE_ICON ,
126
127
LOG_ICON ,
127
128
PALETTE_ICON ,
@@ -4835,6 +4836,110 @@ export class PrintToPDFActionComponent extends ActionComponent {
4835
4836
4836
4837
////////////////////////////////////////////////////////////////////////////////
4837
4838
4839
+ export class FocusWidgetActionComponent extends ActionComponent {
4840
+ static classInfo = makeDerivedClassInfo ( ActionComponent . classInfo , {
4841
+ componentPaletteGroupName : "GUI" ,
4842
+ properties : [
4843
+ makeExpressionProperty (
4844
+ {
4845
+ name : "widget" ,
4846
+ type : PropertyType . MultilineText ,
4847
+ propertyGridGroup : specificGroup
4848
+ } ,
4849
+ "widget"
4850
+ )
4851
+ ] ,
4852
+ defaultValue : { } ,
4853
+ icon : FOCUS_WIDGET_ICON ,
4854
+ componentHeaderColor : "#DEB887" ,
4855
+ execute : ( context : IDashboardComponentContext ) => {
4856
+ const widget = context . evalProperty < number > ( "widget" ) ;
4857
+ if ( widget == undefined ) {
4858
+ context . throwError ( `Invalid Widget property` ) ;
4859
+ return ;
4860
+ }
4861
+
4862
+ const widgetInfo =
4863
+ context . WasmFlowRuntime . getWidgetHandleInfo ( widget ) ;
4864
+
4865
+ if ( ! widgetInfo ) {
4866
+ context . throwError ( `Invalid Widget handle` ) ;
4867
+ return ;
4868
+ }
4869
+
4870
+ const widgetContext = new DashboardComponentContext (
4871
+ context . WasmFlowRuntime ,
4872
+ widgetInfo . flowStateIndex ,
4873
+ widgetInfo . componentIndex
4874
+ ) ;
4875
+
4876
+ const executionState =
4877
+ widgetContext . getComponentExecutionState < any > ( ) ;
4878
+
4879
+ if ( ! executionState ) {
4880
+ context . throwError ( `Widget not initialized` ) ;
4881
+ return ;
4882
+ }
4883
+
4884
+ if ( ! executionState . focus ) {
4885
+ context . throwError ( `Widget doesn't support focus` ) ;
4886
+ return ;
4887
+ }
4888
+
4889
+ executionState . focus ( ) ;
4890
+
4891
+ context . propagateValueThroughSeqout ( ) ;
4892
+ }
4893
+ } ) ;
4894
+
4895
+ widget : string ;
4896
+
4897
+ override makeEditable ( ) {
4898
+ super . makeEditable ( ) ;
4899
+
4900
+ makeObservable ( this , {
4901
+ widget : observable
4902
+ } ) ;
4903
+ }
4904
+
4905
+ getInputs ( ) {
4906
+ return [
4907
+ {
4908
+ name : "@seqin" ,
4909
+ type : "any" as ValueType ,
4910
+ isSequenceInput : true ,
4911
+ isOptionalInput : true
4912
+ } ,
4913
+ ...super . getInputs ( )
4914
+ ] ;
4915
+ }
4916
+
4917
+ getOutputs ( ) {
4918
+ return [
4919
+ {
4920
+ name : "@seqout" ,
4921
+ type : "null" as ValueType ,
4922
+ isSequenceOutput : true ,
4923
+ isOptionalOutput : true
4924
+ } ,
4925
+ ...super . getOutputs ( )
4926
+ ] ;
4927
+ }
4928
+
4929
+ getBody ( flowContext : IFlowContext ) : React . ReactNode {
4930
+ if ( ! this . widget ) {
4931
+ return null ;
4932
+ }
4933
+ return (
4934
+ < div className = "body" >
4935
+ < pre > { this . widget } </ pre >
4936
+ </ div >
4937
+ ) ;
4938
+ }
4939
+ }
4940
+
4941
+ ////////////////////////////////////////////////////////////////////////////////
4942
+
4838
4943
registerClass ( "StartActionComponent" , StartActionComponent ) ;
4839
4944
registerClass ( "EndActionComponent" , EndActionComponent ) ;
4840
4945
registerClass ( "InputActionComponent" , InputActionComponent ) ;
@@ -4902,3 +5007,5 @@ registerClass("NoopActionComponent", NoopActionComponent);
4902
5007
registerClass ( "CommentActionComponent" , CommentActionComponent ) ;
4903
5008
4904
5009
registerClass ( "PrintToPDFActionComponent" , PrintToPDFActionComponent ) ;
5010
+
5011
+ registerClass ( "FocusWidgetActionComponent" , FocusWidgetActionComponent ) ;
0 commit comments