[comp.sys.atari.st] Use of Objc_Edit function.

wkk@cbnewsl.ATT.COM (wesley.k.kaplow) (03/15/89)

I have been trying to write my own code for handling editing
an editble field in an object.  The code below is my test case.
The resource file and its associated editable objects work correctly if
I call the standard "form_do()" routine, so I don't think that resource
file is the problem.  

When the code runs it draws the object correctly
and the first call the objc_edit turns on the text cursor at the END of
the editable field define of object EDIT1.  However, subsequent calls
to objc_edit with the EDCHAR flag produces no results other than to toggle
the cursor on and off.  I have not checked to see if EDCHAR is defined
correctly, but I will do that when I get home tonight.  In the
"while" loop, the values of idx and nidx never change, and I believe 
that this is incorrect.  What am I doing wrong?


BTW: Just in case you want to try this code for yourself, create a dialog
     named NAMEDLOG containing an object with an editable field named EDIT1.
     Name the resource file resource.rsc.

I am using Laser C version 2.0.   Please, someone lift me from my ignorance.



#include <gemdefs.h>
#include <obdefs.h>
#include <osbind.h>
#include "resource.h"

char *edit1 = "Test  ";

main()
{
	OBJECT *dialog;
	int idx, nidx;
	int chr;
	char str[50];

	appl_init();

	if (!rsrc_load(".\\RESOURCE.RSC")) {
	graf_mouse(ARROW, 0x0L);
	form_alert(1, "[3][Cannot find|resource.rsc file|Terminating ...][OK]");
		exit(1);
	}

	rsrc_gaddr(0, NAMEDLOG, &dialog);

	((TEDINFO *)dialog[EDIT1].ob_spec)->te_ptext = edit1;
	((TEDINFO *)dialog[EDIT1].ob_spec)->te_txtlen = 5;

	dialog->ob_x = 50;
	dialog->ob_y = 50;

	/* draw the object, this works fine */

	objc_draw(dialog, 0, 10, 0, 0, 300, 300);

	idx = 0;
	objc_edit(dialog, EDIT1, 0, &idx, EDINIT, &nidx);
	while(1) {
		chr = Crawcin();		/* get the next character */
		chr &= 0xff;			/* mask off the nuaghty bits */
		if(chr == 0x0D) exit(1);	/* exit if CR */
		objc_edit(dialog, EDIT1, chr, &idx, EDCHAR, &nidx); /* no go */
		sprintf(str,"[1][idx = %d  nidx = %d][EXIT]", idx, nidx);
		form_alert(1, str); /* just checking */

	}
/*	do_dialog(dialog);		This works fine */
}

Wesley Kaplow
AT&T Bell Laboratories

USENET: att!wayback!wkk
AT&T: 201-386-4634