disable remove button for default item

This commit is contained in:
chombier 2001-03-18 00:29:09 +00:00
parent 36652618f3
commit bfc1c037c0
1 changed files with 21 additions and 5 deletions

View File

@ -545,6 +545,8 @@ pascal short MyDlogWListFilter( DialogPtr dptr, EventRecord *evt, short *item)
Cell tempCell; Cell tempCell;
static unsigned long lastTime = 0; static unsigned long lastTime = 0;
static char shortcut[] = {0,0,0,0,0,0,0,0,0,0,0}; static char shortcut[] = {0,0,0,0,0,0,0,0,0,0,0};
Str255 tempString;
SetPort(dptr); SetPort(dptr);
if ((evt->what == keyDown)||(evt->what == autoKey)) if ((evt->what == keyDown)||(evt->what == autoKey))
{ {
@ -562,6 +564,7 @@ pascal short MyDlogWListFilter( DialogPtr dptr, EventRecord *evt, short *item)
switch(evt->message & charCodeMask) switch(evt->message & charCodeMask)
{ {
case 'e': case 'e':
case 'E':
if (GetCurrentSelection(currentList, NULL, NULL)) { if (GetCurrentSelection(currentList, NULL, NULL)) {
*item = kChange; *item = kChange;
} else { } else {
@ -570,7 +573,9 @@ pascal short MyDlogWListFilter( DialogPtr dptr, EventRecord *evt, short *item)
} }
break; break;
case 'r': case 'r':
if (!IsDefaultSelected(currentList)) { case 'R':
if ( GetCurrentSelection(currentList, NULL, tempString)
&& !IsDefaultLabel(tempString) ) {
*item = kRemove; *item = kRemove;
} else { } else {
evt->what == nullEvent; evt->what == nullEvent;
@ -578,9 +583,11 @@ pascal short MyDlogWListFilter( DialogPtr dptr, EventRecord *evt, short *item)
} }
break; break;
case 'n': case 'n':
case 'N':
*item = kNew; *item = kNew;
break; break;
case 'd': case 'd':
case 'D':
if (GetCurrentSelection(currentList, NULL, NULL)) { if (GetCurrentSelection(currentList, NULL, NULL)) {
*item = kDuplicate; *item = kDuplicate;
} else { } else {
@ -589,11 +596,12 @@ pascal short MyDlogWListFilter( DialogPtr dptr, EventRecord *evt, short *item)
} }
break; break;
default: default:
return(FALSE); evt->what == nullEvent;
return FALSE;
break; break;
} }
FlashButton(dptr, *item); FlashButton(dptr, *item);
return (-1); return -1;
} }
else // a normal key else // a normal key
@ -637,6 +645,7 @@ pascal short MyDlogWListFilter( DialogPtr dptr, EventRecord *evt, short *item)
LAutoScroll(currentList); LAutoScroll(currentList);
Hilite(dptr, kRemove, IsDefaultSelected(currentList) ? 255 : 0); Hilite(dptr, kRemove, IsDefaultSelected(currentList) ? 255 : 0);
Hilite(dptr, kChange, 0); Hilite(dptr, kChange, 0);
Hilite(dptr, kDuplicate, 0);
return(FALSE); return(FALSE);
} }
else //CCP go to right list item based on keystroke else //CCP go to right list item based on keystroke
@ -656,6 +665,7 @@ pascal short MyDlogWListFilter( DialogPtr dptr, EventRecord *evt, short *item)
Hilite(dptr, kRemove, IsDefaultSelected(currentList) ? 255 : 0); Hilite(dptr, kRemove, IsDefaultSelected(currentList) ? 255 : 0);
Hilite(dptr, kChange, 0); Hilite(dptr, kChange, 0);
Hilite(dptr, kDuplicate, 0);
} }
} }
} }
@ -802,10 +812,15 @@ void EditConfigType(ResType ConfigResourceType, Boolean (*EditFunction)(StringPt
if (numberofitems) LSetSelect(1, theCell, thelist); if (numberofitems) LSetSelect(1, theCell, thelist);
LSetDrawingMode(1, thelist); LSetDrawingMode(1, thelist);
/* first item is always <default> can't be deleted */ /* item <default> can't be deleted */
if ( IsDefaultSelected(thelist) ) { if ( IsDefaultSelected(thelist) ) {
Hilite(dptr, kRemove, 255); Hilite(dptr, kRemove, 255);
} }
if (!GetCurrentSelection(thelist, NULL, NULL)) {
Hilite(dptr, kRemove, 255);
Hilite(dptr, kChange, 255);
Hilite(dptr, kDuplicate, 255);
}
currentHead = theHead; //let dialog filter know about the list currentHead = theHead; //let dialog filter know about the list
while (ditem > 1) { while (ditem > 1) {
@ -814,7 +829,8 @@ void EditConfigType(ResType ConfigResourceType, Boolean (*EditFunction)(StringPt
switch(ditem) switch(ditem)
{ {
case kRemove: case kRemove:
if ( GetCurrentSelection(thelist, &theCell, ItemName) && !IsDefaultLabel(ItemName) ) { if ( GetCurrentSelection(thelist, &theCell, ItemName)
&& !IsDefaultLabel(ItemName) ) {
deleteItem(&theHead,ItemName);//delete it from the linked list deleteItem(&theHead,ItemName);//delete it from the linked list
LDelRow(1,theCell.v,thelist); LDelRow(1,theCell.v,thelist);
theCell.v--; theCell.v--;