from PSPApp import *

def ScriptProperties():
    return {
        'Author': u'Corel Corporation',
        'Copyright': u'Copyright (c) 2002-2006 Corel Corporation. All rights reserved.',
        'Description': "Emulate the Corel behavior of toggling from the current tool to the selection tool.",
        'Host': u'Paint Shop Pro',
        'Host Version': u'8.00'
        }

def Do(Environment):
    # get the name of the current tool.   Do this by calling SetTool but
    # specifying an empty string for the new tool name.  This returns the
    # current tool name without changing tools
    CurrentTool = App.Do( Environment, 'SelectTool', { 'Tool': '' } )
  
    if CurrentTool == 'FreehandSelection':
        # we are on the freehand tool, select the previous tool
        App.Do( Environment, 'SelectPreviousTool' )
    else:
        # not on the freehand tool, go to it
        App.Do( Environment, 'SelectTool', { 'Tool':'FreehandSelection' } )
                          