rkjnsnLe 24/03/2010 à 22:21
I'm trying to use a textedit widget in a window I have created and activated, but the textedit is not being properly redrawn. For example, when you press backspace, the cursor backs up and the character is removed from the buffer, but it is left on the screen. If you then type another, it will then replace the other one on the screen. When I try to isolate the code (as below), it works fine, and I can't figure out why this works and my program doesn't.
(P.S., If I build this code with OPTIMIZE_RAM_CALLS, it crashes with the message "Line 1111 Emulator" on the TI-89 Titanium. Is this a bug?)
#include <tigcclib.h>
#define BUFFER_SIZE 200
TEXT_EDIT gsTextEdit;
CALLBACK void textEventHandler(EVENT *psEvent)
{
if (psEvent->Type == CM_KEYPRESS && psEvent->extra.Key.Code == KEY_ENTER)
ER_throw (1); /* Exit the event loop */
if (!TE_handleEvent (&gsTextEdit, psEvent))
EV_defaultHandler (psEvent);
}
void _main(void)
{
WINDOW sWindow;
HANDLE hInputBuffer;
char *pInputBuffer;
if (!WinOpen(&sWindow, &(WIN_RECT){ScrRect->xy.x0,
ScrRect->xy.y0, ScrRect->xy.x1, ScrRect->xy.y1}, WF_NOBORDER))
return;
WinFont(&sWindow, F_6x8);
WinActivate(&sWindow);
WinClr(&sWindow);
sWindow.Flags &= ~WF_DIRTY;
hInputBuffer = HeapAlloc(BUFFER_SIZE);
pInputBuffer = HeapDeref(hInputBuffer);
memset(pInputBuffer, 0, BUFFER_SIZE);
TE_openFixed(&gsTextEdit, &sWindow, &(WIN_RECT){10, 10, 159, 17},
pInputBuffer, BUFFER_SIZE - 1, TE_MORE_ELLIPSES);
TE_select(&gsTextEdit, 0, 0);
CU_start(); /* Start the cursor */
EV_captureEvents (textEventHandler);
TRY
EV_eventLoop ();
ONERR
EV_captureEvents (NULL);
ENDTRY
CU_stop(); /* Stop the cursor */
HeapFree(hInputBuffer);
WinClose(&sWindow);
}