Hippocode Posted November 29, 2012 Share Posted November 29, 2012 I'm trying to understand the whole event part of a PIO. Is it possible to change the visibility of a widget in a PIO, depending on the choice or change of one of the widgets ? Lets say param 1 changes, widget param2 should be hidden. I tried to change the visibility in kParametricRecalculate, but it seems that ain't possible. PROCEDURE Sample; VAR objectName : STRING; objectHand : HANDLE; recordHand : HANDLE; wallHand : HANDLE; theEvent, message : LONGINT; result : BOOLEAN; x, y, z , diffAng : REAL; is3D, scaleText : BOOLEAN; widgID, changeID : LONGINT; grpType : LONGINT; prmIndex : INTEGER; oldValue : STRING; oldScale, newScale : REAL; oldName, newName : STRING; BEGIN result := GetCustomObjectInfo(objectName, objectHand, recordHand, wallHand); vsoGetEventInfo(theEvent, message ); CASE theEvent OF 5: {kObjOnInitXProperties} BEGIN result:= SetObjPropVS(8, TRUE); {kObjXPropHasUIOverride} result:= SetObjPropVS(12, TRUE); {kObjXHasCustomWidgetVisibilities} SetPrefInt( 590, 1 ); {varParametricEnableStateEventing, kParametricStateEvent_ResetStatesEvent} result := SetObjPropVS(18, TRUE); {kObjXPropAcceptStates} result:= vsoInsertAllParams; END; 44: {kObjOnAddState} BEGIN message := vsoStateAddCurrent( objectHand, message ); END; 3: {kParametricRecalculate} BEGIN Rect( 0mm, 0mm, 20mm, -10mm ); IF vsoStateGetParamChng( objectHand, widgID, prmIndex, oldValue ) THEN BEGIN MoveTo( 0,-30mm ); CreateText( Concat( 'Object parameter just changed! widgetID=', widgID, ' paramIndex=', prmIndex,' OldValue=', oldValue ) ); vsoWidgetSetVisible( 2, FALSE ); END; vsoStateClear( objectHand ); END; 41: {kObjOnWidgetPrep} BEGIN vsoWidgetSetVisible( 1, TRUE ); vsoWidgetSetVisible( 2, TRUE ); vsoWidgetSetVisible( 3, TRUE ); vsoSetEventResult( -8 {kObjectEventHandled} ); END; END; END; RUN( Sample ); Quote Link to comment
Vectorworks, Inc Employee klinzey Posted November 29, 2012 Vectorworks, Inc Employee Share Posted November 29, 2012 All the Widget Visibilities are done during kObjOnWidgetPrep. Every time the OIP or the preferences dialog needs to be drawn the object will run the kObjOnWidgetPrep event. You can do just about any logical test you want during the event but you don't want to create or modify anything during the event. So thing checking the value of parameters is fine. vsoWidgetSetVisible( 1, pValue=1); vsoWidgetSetVisible( 2, pChoice='None'); vsoWidgetSetVisible( 3, pBoolean); Quote Link to comment
Miguel Barrera Posted November 29, 2012 Share Posted November 29, 2012 It can be done in the reset event with SetParameterVisibility(inPlugin: HANDLE; inParameterName: STRING; inSetVisible: BOOLEAN); but SetObjPropVS(12,TRUE) should not be included or set to FALSE; Otherwise by setting it to TRUE, the widget visibility must be handled in the event 41 (kObjOnWidgetPrep). If you are not changing any popup values in code, which are also handled in event 41, then doing it during the reset event works best. Quote Link to comment
Hippocode Posted December 3, 2012 Author Share Posted December 3, 2012 While building my code, the object started behaving weird. Its a 2dpath object with text in it, the text gets duplicated outside the object, on a different coordinate? BEGIN { retrieve plug-in object information } result:= GetCustomObjectInfo(objName,objHd,objrecHd,wHd); vsoGetEventInfo(theEvent, theButton); CASE theEvent OF 5:{kObjOnInitXProperties:} BEGIN status:= SetObjPropVS(18, TRUE); {kObjXPropAcceptStates} status:= SetObjPropVS(8, TRUE); {kObjXPropHasUIOverride} status:= SetObjPropCharVS(kObjXPropSpecialEdit,Chr(kReshapeSpecialEdit)); status:= SetObjPropVS(kObjXIs2DSurfaceEligible,TRUE); status:= SetObjPropCharVS(kObjXPropEditGroup,Chr(kObjXPropEditGroupPath)); status:= SetObjPropCharVS(11, Chr(1)); status:= SetObjPropCharVS(11, Chr(2)); status:= vsoInsertAllParams; END; 3: {kParametricRecalculate} BEGIN IF vsoStateGetParamChng( objHd, widgID, prmIndex, oldValue ) THEN BEGIN {oldName := Num2Str(0,PPARAM2);} {SetParameterVisibility(objHd,'param1',TRUE);} END; vsoStateClear(objHd); END; 41: {kObjOnWidgetPrep} BEGIN vsoWidgetSetVisible( 1, TRUE ); vsoSetEventResult( -8 {kObjectEventHandled} ); END; END; { if the plug-in object info was successfully retrieved } IF result THEN BEGIN {2d shape} Main; END; END; Quote Link to comment
Vectorworks, Inc Employee klinzey Posted December 3, 2012 Vectorworks, Inc Employee Share Posted December 3, 2012 "{ if the plug-in object info was successfully retrieved } IF result THEN BEGIN {2d shape} Main;" should be in the 3: {kParametricRecalculate} case. Where it is now it's being executed for every event which is VERY BAD! Quote Link to comment
Hippocode Posted December 3, 2012 Author Share Posted December 3, 2012 Ah Thanks Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.