unit Modal2; interface uses TransSkel, ButtonGlobals; procedure DoModal2; implementation const findItem = 1; cancelItem = 2; staticTextItem = 3; editTextItem = 4; outlineItem = 5; var defaultButton: Integer; {--------------------------------------------------------------------} { Dialog 2 procedures } {--------------------------------------------------------------------} procedure OutlineButton (dlog: DialogPtr; item: Integer); begin SkelDrawButtonOutline(SkelGetDlogCtl(dlog, defaultButton)); end; procedure SetDefaultButton (dlog: DialogPtr; item: Integer); var r: Rect; begin defaultButton := item; SkelGetDlogRect(dlog, defaultButton, r); { get button rect } InsetRect(r, -4, -4); { expand it } SkelSetDlogRect(dlog, outlineItem, r); { use for outline item } SkelSetDlogProc(dlog, outlineItem, @OutlineButton); SkelDrawButtonOutline(SkelGetDlogCtl(dlog, defaultButton)); end; procedure DoModal2; var filter: ModalFilterProcPtr; dlog: DialogPtr; savePort: GrafPtr; item: Integer; newDefault: Integer; str: Str255; loop: Boolean; begin dlog := GetNewDialog(modal2Res, nil, WindowPtr(-1)); if (dlog = DialogPtr(nil)) then begin SysBeep(1); exit(DoModal2); end; SkelPositionWindow(dlog, skelPositionOnMainDevice, horizRatio, vertRatio); GetPort(savePort); SetPort(dlog); SetDefaultButton(dlog, cancelItem); ShowWindow(dlog); loop := true; while (loop) do begin filter := SkelDlogFilter(nil, true); SkelDlogDefaultItem(defaultButton); SkelDlogCancelItem(cancelItem); SkelDlogTracksCursor(true); ModalDialog(filter, item); SkelRmveDlogFilter; if ((item = findItem) or (item = cancelItem)) then loop := false else begin SkelGetDlogStr(dlog, editTextItem, str); if (length(str) > 0) then newDefault := findItem else newDefault := cancelItem; if (newDefault <> defaultButton) then begin SkelEraseButtonOutline(SkelGetDlogCtl(dlog, defaultButton)); SetDefaultButton(dlog, newDefault); end; end; end; DisposeDialog(dlog); SetPort(savePort); end; end.