Amiga.org
Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: jahc on January 11, 2004, 11:10:50 PM
-
I posted this message on the AmigaC mailing list.. I've reposted here as there have been no responses yet:
I've created a custom string gadget editing hook, but it wont display text in my string gadget while I type.. but when I hit enter, the text is printed in my windows listbrowser alright. So the text is being stored somewhere, but not displayed.. I'm using a Reaction
string gadget. Heres the relevant parts to my program.. I hope it makes sense. Btw this hook is just a test hook, I will be make it do other stuff later..
#define SG_STRLEN 600
struct Vars
{
struct StringInfo sgg_StrInfo;
struct StringExtend sgg_Extend;
struct Hook sgg_Hook;
UBYTE sgg_Buff[SG_STRLEN];
UBYTE sgg_WBuff[SG_STRLEN];
UBYTE sgg_UBuff[SG_STRLEN];
} *vars;
ULONG str_hookRoutine(struct Hook *hook, struct SGWork *sgw, ULONG
*msg)
{
UBYTE *work_ptr;
ULONG return_code;
/* Hook must return non-zero if command is supported.
** This will be changed to zero if the command is unsupported.
*/
return_code = ~0L;
if (*msg == SGH_KEY)
{
if ((sgw->EditOp == EO_REPLACECHAR) ||
(sgw->EditOp == EO_INSERTCHAR))
{
if((int)sgw->Code == 66) sgw->WorkBuffer[sgw->BufferPos -
1] = 'Z'; else
sgw->WorkBuffer[sgw->BufferPos - 1] = (int)sgw->Code;
}
}
else if (*msg == SGH_CLICK)
{
/* mouse click
** zero the digit clicked on
*/
if (sgw->BufferPos < sgw->NumChars)
{
work_ptr = sgw->WorkBuffer + sgw->BufferPos;
*work_ptr = '0';
}
}
else
{
/* UNKNOWN COMMAND
** hook should return zero if the command is not supported.
*/
return_code = 0;
}
return(return_code);
}
#define ASM __asm
#define REG(x) register __ ## x
ULONG ASM
hookEntry(REG(a0) struct Hook *h, REG(a2) VOID *o, REG(a1) VOID *msg)
{
return ((*(ULONG (*)(struct Hook *,VOID *,VOID *))(h->h_SubEntry))
(h, o, msg));
}
/* This simple function is used to initialize a Hook */
VOID InitHook (struct Hook *h, ULONG (*func)(struct Hook *hook,
struct SGWork *sgw, ULONG *msg), VOID *data)
{
/* Make sure a pointer was passed */
if (h)
{
/* Fill in the Hook fields */
h->h_Entry = (ULONG (*)()) hookEntry;
h->h_SubEntry = (HOOKFUNC)func;
h->h_Data = data;
}
}
struct Gadget *string_gadget;
int main()
{
(snipped large LAYOUT gadget stuff)
LAYOUT_AddChild, string_gadget =(Gadget*) StringObject,
STRINGA_MaxChars, 600,
GA_RelVerify, TRUE,
GA_UserInput, TRUE,
LAYOUT_DeferLayout, TRUE,
GA_ID, 1,
StringEnd, LayoutEnd;
(/snipped large LAYOUT gadget stuff)
vars = (struct Vars *)AllocMem(sizeof(struct Vars),MEMF_CLEAR);
if (vars != NULL)
{
vars->sgg_Extend.EditHook = &(vars->sgg_Hook);
vars->sgg_Extend.WorkBuffer = vars->sgg_WBuff;
vars->sgg_StrInfo.Buffer = vars->sgg_Buff;
vars->sgg_StrInfo.UndoBuffer = vars->sgg_UBuff;
vars->sgg_StrInfo.MaxChars = 600;
vars->sgg_StrInfo.Extension = &(vars->sgg_Extend);
string_gadget->Flags = GFLG_GADGHCOMP | GFLG_STRINGEXTEND;
string_gadget->SpecialInfo = &(vars->sgg_StrInfo);
InitHook (&(vars->sgg_Hook), str_hookRoutine, NULL);
//RA_SetUpHook(vars->sgg_Hook,string_gadget,NULL);
}
etc etc
}
-
I don't know much of Intuition programming but I suspect you must
set SGA_USE flag there...
sgw->Actions |= SGA_USE;
(RKRM / Custom String Editing / Actions with SGH_KEY)
-
I don't know much of Intuition programming but I suspect you must
set SGA_USE flag there...
sgw->Actions |= SGA_USE;
I've tried sgw->Actions |= SGA_USE; and sgw->Actions |= SGA_REDISPLAY; but neither of them makes a difference... :/
-
Try setting the colors in your RastPort to sensible values.
Black text on a black background might be hard to read. :-D
-
are you trying to help or what? I havent changed any colours.. the cursor doesnt move.. I've checked for same colour text already.
-
jahc wrote:
are you trying to help or what? I havent changed any colours.. the cursor doesnt move.. I've checked for same colour text already.
Well I had similar problem with Intuition(tm) before.
I didn't change any colors either.
It defaulted to color X text on color X background and was invisible.
I have never used Reaction.
Yes I was trying to help but since u don't appreciate it I won't help anymore. Bye.
-
Well I had similar problem with Intuition(tm) before.
I didn't change any colors either.
It defaulted to color X text on color X background and was invisible.
I have never used Reaction.
Yes I was trying to help but since u don't appreciate it I won't help anymore. Bye
Sorry, I thought you were just being smart. People have replied like that to me before. I appreciate all help btw.