Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!zaphod.mps.ohio-state.edu!caen!ox.com!heifetz!tbomb!time From: time@ice.com (Tim Endres) Newsgroups: comp.sys.mac.programmer Subject: Re: Dialog Filter - blocking returns Message-ID: <1CE00001.ik3fyf@tbomb.ice.com> Date: 20 Jun 91 01:53:13 GMT Reply-To: time@ice.com Organization: ICE Engineering, Inc. Lines: 110 X-Mailer: uAccess - Mac Release: 1.5 In article <1991Jun19.203617.553@hubcap.clemson.edu>, jcocon@hubcap.clemson.edu (james c oconnor) writes: > I am writing a dialog filter routine which checks the condition of the > default button. If the button is hilited 255 then the return is > converted to a tab. One problem, it doesn't work. Here is the code: Well, Here is the code I use to insert the bullet characters when the user is typing in a password... It does a lot of shit. I catch Apple-Period for Cancel, Escape for Cancel, and clipboarding. Comparing the two, the only difference I see is the two lines: event->message &= ~0xFF; event->message |= TAB; The "&= ~0xFF" zeros the entire message field. I don't think you wish to do this. I just zero the lower byte, since I think the "key code" is required by the ModalDialog() algorithms... tim. ------ pascal Boolean LoginFilter(myDialog, myEvent, myItem) DialogPtr myDialog; EventRecord *myEvent; short *myItem; { int result = FALSE, myascii, virtual_key; char title[256]; Handle myhandle; short type, psuedo_cancel = 0; Rect myrect; #pragma unused(myEvent) modal_run_state_machine(); if (myEvent->what == keyDown) { myascii = myEvent->message & 255; virtual_key = (myEvent->message >> 8) % 256; if ((myEvent->modifiers & 0x0100) != 0) { if (myascii == 'x' || myascii == 'X') { DlgCut(myDialog); ZeroScrap(); TEToScrap(); result = TRUE; } else if (myascii == 'c' || myascii == 'C') { DlgCopy(myDialog); ZeroScrap(); TEToScrap(); result = TRUE; } else if (myascii == 'v' || myascii == 'V') { if ((((DialogPeek)myDialog)->editField + 1) == user_password_text_item) { SysBeep(0); result = TRUE; } else { DlgPaste(myDialog); result = TRUE; } } else if (myascii == '.') { psuedo_cancel = 1; } else { /* Suck up stray apple-keys... */ *myItem = 0; result = TRUE; } } else if (myascii == '\015' || myascii == '\003') { *myItem = ((DialogRecord *) myDialog)->aDefItem; result = TRUE; } else if (myascii == 0x1B) { psuedo_cancel = 1; } else if (myascii != 0x09) { if (virtual_key == 0x7C || virtual_key == 0x7D || virtual_key == 0x7B || virtual_key == 0x7E) { result = TRUE; } else if ((((DialogPeek)myDialog)->editField + 1) == user_password_text_item) { if (myascii == 0x08 || virtual_key == 0x47) { /* BACKSPace or CLEAR */ SelIText(myDialog, user_password_text_item, 0, 256); DlgDelete(myDialog); _login_pass_index = 0; result = TRUE; } else { _login_password[_login_pass_index++] = myascii; myEvent->message &= 0xFFFFFF00; myEvent->message |= 0x00A5; result = FALSE; } } } if (psuedo_cancel) { GetDItem(myDialog, 2, &type, &myhandle, &myrect); if (myhandle != NULL && type == (ctrlItem + btnCtrl)) { GetCTitle((ControlHandle)myhandle, title); if (title[0] == '\006' && title[1] == 'C' && title[2] == 'a' && title[3] == 'n' && title[4] == 'c' && title[5] == 'e' && title[6] == 'l') { *myItem = 2; result = TRUE; } } } } return result; } ------------------------------------------------------------- Tim Endres | time@ice.com ICE Engineering | uupsi!ice.com!time 8840 Main Street | Voice FAX Whitmore Lake MI. 48189 | (313) 449 8288 (313) 449 9208