Download Making Your First InDesign Plug-in

Transcript
InDesign Plug-in Cookbook 1
#10045
Step 2: Add a DropDownListWidget
Let's add a DropDownListWidget onto our dialog.
Step 2.1: Add a Widget ID for Our DropDownListWidget
First, to add a widget ID for our DropDownListWidget, open WFPID.h in your IDE.
Around line 63, you will find widget definitions for the dialog and information icon button.
// WidgetIDs:
DECLARE_PMID(kWidgetIDSpace, kWFPDialogWidgetID, kWFPPrefix + 0)
DECLARE_PMID(kWidgetIDSpace, kWFPIconSuiteWidgetID, kWFPPrefix + 1)
This is where we declare the widget ID for our DropDownListWidget.
On the following line, add:
// DropDownList widget ID
DECLARE_PMID(kWidgetIDSpace, kWFPDropDownListWidgetID, kWFPPrefix + 2)
Step 2.2: Define String Keys for List Items on Our DropDownListWidget
Next, let's define string keys for the items in the DropDownList. InDesign has a base type object
called PMString. This string is used extensively for UI strings, and has a locale-based string lookup
mechanism behind the scenes for automatic string translation. The translated strings are defined
in a string table resource, and by specifying a string by its key, InDesign will automatically replace
it with the corresponding localized string. If you look at WFPID.h after line 67, you can see several
string keys defined there.
Now, let's define a string key for the DropDownListWidget items. Find the following in WFPID.h:
// Other StringKeys:
#define kWFPDialogTitleKey
#define kWFPAboutBoxStringKey
kWFPStringPrefix "kWFPDialogTitleKey"
kWFPStringPrefix "kWFPAboutBoxStringKey"
Right after that, add these lines:
#define
#define
#define
#define
kWFPDropDownItem_1Key
kWFPDropDownItem_2Key
kWFPDropDownItem_3Key
kWFPDropDownItem_4Key
kWFPStringPrefix
kWFPStringPrefix
kWFPStringPrefix
kWFPStringPrefix
"kWFPDropDownItem_1Key"
"kWFPDropDownItem_2Key"
"kWFPDropDownItem_3Key"
"kWFPDropDownItem_4Key"
//
//
//
//
listitem
listitem
listitem
listitem
If you know what your string key will be (e.g. kWFP_TunaKey), it might easier to define the key using the string, so that you can find it easier at a later time.
Step 2.3: Define Locale-specific Strings for List Items on Our DropDownListWidget
Next, we will define the string table resource entries that correspond to these string keys we just
defined. These string tables are defined in WFP_enUS.fr and WFP_jaJP.fr, for use under the US
English and Japanese locales, respectively. These two resource files are included by WFP.fr.
Ok, let's start by defining the US English string table entries. If you open WFP_enUS.fr, you will see
that the string keys and the English strings are paired up, as shown below. Let's add strings for the
4 string keys we just added. Look for the following in WFP_enUS.fr:
Making Your First InDesign Plug-In
21