jcocon@hubcap.clemson.edu (james c oconnor) (06/20/91)
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: pascal Boolean ReturnFilter(DialogPtr dlog,EventRecord *event,int *hit) { char c; ControlHandle Hndl; int type; Rect r; if (event->what == keyDown || event->what == autoKey){ if ((c=event->message & charCodeMask)==CR || c==ENTER){ GetDItem(dlog,1,&type,&Hndl,&r); if (!(*Hndl)->contrlHilite){ event->message &= ~0xFF; event->message |= TAB; c = TAB; } } if (c == CR || c == ENTER){ *hit = 1; return TRUE; } } return FALSE; } TAB, ENTER, and CR are all #defined to be 0x??, and should work since they do in a much more elaborate filter I wrote which does this very thing, plus a whole bunch. Thanks Jim
jtn@potomac.ads.com (John T. Nelson) (06/20/91)
Your code is VERY similar in function to my own and I have the same problem and I wish I knew how to solve it! I can't trap '\r' and other characters without them showing up in the text field of the dialog items. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ORGANIZATION: BLETCH (Bletcherous League of Evil Twisted Computer Hackers) UUCP: kzin!speaker@mimsy.umd.edu INTERNET: jtn@potomac.ads.com SPOKEN: Dark Hacker PHONE: (703) 243-1611 FAVORITE MAGAZINE: Midnight Engineer TWISTED DIABOLICAL LAUGH: Mwahh ah ha ha hah ha ha ha! The Mythos of Dark Hacker: "Controlled by the sinister and shadowy "suits" Dark Hacker now employs the tools of computer science to free himself from the suit's will. By day he is a lackey... but at night when the city sleeps he becomes.... DARK HACKER!" =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
time@ice.com (Tim Endres) (06/20/91)
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