Welcome, Guest. Please login or register.

Author Topic: dev: no text in string gadget  (Read 2404 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline jahcTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 521
    • Show only replies by jahc
    • http://wookiechat.amigarevolution.com
dev: no text in string gadget
« 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
}
 

Offline itix

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 2380
    • Show only replies by itix
Re: dev: no text in string gadget
« Reply #1 on: January 12, 2004, 12:40:56 AM »
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)
My Amigas: A500, Mac Mini and PowerBook
 

Offline jahcTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 521
    • Show only replies by jahc
    • http://wookiechat.amigarevolution.com
Re: dev: no text in string gadget
« Reply #2 on: January 12, 2004, 02:56:59 AM »
Quote
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... :/

 

Offline ChaosLord

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show only replies by ChaosLord
    • http://totalchaoseng.dbv.pl/news.php
Re: dev: no text in string gadget
« Reply #3 on: January 15, 2004, 01:29:39 PM »
Try setting the colors in your RastPort to sensible values.

Black text on a black background might be hard to read. :-D
Wanna try a wonderfull strategy game with lots of handdrawn anims,
Magic Spells and Monsters, Incredible playability and lastability,
English speech, etc. Total Chaos AGA
 

Offline jahcTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 521
    • Show only replies by jahc
    • http://wookiechat.amigarevolution.com
Re: dev: no text in string gadget
« Reply #4 on: January 16, 2004, 04:24:53 AM »
are you trying to help or what? I havent changed any colours.. the cursor doesnt move.. I've checked for same colour text already.
 

Offline ChaosLord

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show only replies by ChaosLord
    • http://totalchaoseng.dbv.pl/news.php
Re: dev: no text in string gadget
« Reply #5 on: January 16, 2004, 08:08:42 PM »
Quote

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.
Wanna try a wonderfull strategy game with lots of handdrawn anims,
Magic Spells and Monsters, Incredible playability and lastability,
English speech, etc. Total Chaos AGA
 

Offline jahcTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 521
    • Show only replies by jahc
    • http://wookiechat.amigarevolution.com
Re: dev: no text in string gadget
« Reply #6 on: January 16, 2004, 09:59:15 PM »
Quote
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.