# Copyright 2009 Autodesk, Inc.  All rights reserved.
# Use of this software is subject to the terms of the Autodesk license agreement 
# provided at the time of installation or download, or which otherwise accompanies
# this software in either electronic or hard copy form.
#
# Script description:
# Shows how FBMessageBoxGetUserValue can be used to select options or as an Ok-Cancel dialog.
#
# Topic: FBMessageBoxGetUserValue, FBMessageBox
#

from pyfbsdk import *

# note that the last params of FBMessageBoxGetUserValue indicates if the last button act as a cancel button.

# if lastButtonIsCancel is set to True (its default value), and you click the last displayed button, the value is NOT updated.
lastButtonIsCancel = True
btn, value = FBMessageBoxGetUserValue("Rename","Enter new name:", "", FBPopupInputType.kFBPopupString,"Ok","Cancel", None, 1, lastButtonIsCancel)

if btn == 1:
    msg = "Name has been changed to %s" % (value)
else:
    msg = "Name has not been changed, value has not been updated."
FBMessageBox("What happened:", msg, "Ok")

# if lastButtonIsCancel is set to False, and you click any button the user value is updated
lastButtonIsCancel = False
btn, value = FBMessageBoxGetUserValue("Select Choices","Enter a value and select an action:", "", FBPopupInputType.kFBPopupString,"Do this","Do that", "Do it that way", 1, lastButtonIsCancel)
if btn == 1:
    msg = "Do this with value %s" % (value)
elif btn == 2:
    msg = "Do that with value %s" % (value)
else:
    msg = "Do it that way with value %s" % (value)
FBMessageBox("What happened:", msg, "Ok")