Jump to content

WidgetButtonResourcePopup


Recommended Posts

Hi All

 

I'm trying to add a resource selector to a Event enabled, custom Widget enabled PIO, that will allow the user to select a texture. I'm using the kWidgetButtonResourcePopup (107) widget type.

 

I can insert the ResourcePopup into the OIP fine (SS Below), however when clicked I'm not getting any button ID passed to kObjOnObjectUIButtonHit (35).

 

image.png.3424f21394a1f5c7e591e34d2de7db8a.png

 

I added a generic test button to make sure it wasn't something else and that successfully passes the Button ID to the kObjOnObjectUIButtonHit event. Is there possibly a different event type I need to look for? Or is there a setting I need to enable?

 

I'm aware I need to use vsoButtonGetResource() to handle the Resource browser, which brings me onto my next question, according to https://developer.vectorworks.net/index.php?title=VS:vsoButtonGetResource the "Parameter name is a string that will receive the resource name" however this appears to be a param I pass to the function and, certainly according to the docs atleast, it will only return a bool. How am I meant to extract the Param string?

 

Relevant code below! Thanks in Advance!

 

kWidgetButtonResourcePopup = 107

def execute():
    global PIO,localized_True_bool

    GetImageButton_ID = 1001
    
    theEvent, eventMessage = None, None
    theEvent, eventMessage = vs.vsoGetEventInfo(theEvent, eventMessage)
    if theEvent == tb.Constants.kObjOnInitXProperties:  # If the event is the initilisation of object propeties

        # Enable custom shape pane
        ok = vs.SetObjPropVS(tb.Constants.kObjXPropHasUIOverride, True)  # Enables customisation fo widgets
        ok = vs.SetObjPropVS(tb.Constants.kObjXHasCustomWidgetVisibilities,
                             True)  # allows PIO to control the widget state in OIP
        ok = vs.SetObjPropVS(tb.Constants.kObjXPropPreference, True)  # Enables preferences menu for PIO

        vs.SetPrefInt(tb.Constants.kParametricEnableStateEventing, 1);
        ok = vs.SetObjPropVS(tb.Constants.kObjXPropAcceptStates, True);


        ok = vs.vsoInsertAllParams()  # Inserts all Parameters into OIP
        bool = vs.vsoAddWidget(GetImageButton_ID,kWidgetButtonResourcePopup,'Select Image')  # Adds Select Image Button
        bool = vs.vsoAppendWidget(tb.widgetTypes.WidgetButton,1234,'Test', 0)


    elif theEvent == tb.Constants.kObjOnWidgetPrep:  # If event is widget Prep

        tb.WidgetGenericPrep()  # Sends message that all widget prep has been completed

    elif theEvent == tb.Constants.kObjOnObjectUIButtonHit:
        vs.AlrtDialog(eventMessage)
        if eventMessage == GetImageButton_ID:
            vs.vsoButtonGetResource(GetImageButton_ID, 97, 0, 0)
    elif theEvent == tb.Constants.kObjOnAddState:
      GenericGetStateChange(eventMessage)
    elif theEvent == tb.Constants.kObjXPropPreference:
        MakePropDialog()
    elif theEvent == tb.Constants.kResetEventID:  # If the event is a object reset
        start_unit_index = tb.SetUnitsToMM()  # Gets Current Units, and sets units to MM
        init()

        vs.Units(start_unit_index)  # Resets Units

        vs.vsoStateClear(PIO.PIHan)

 

Link to comment
  • 3 weeks later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...