EventPending

[method icon] EventPending()

Tests to see if the user has triggered another event

Returns result of type Bool

Applies to: Form


>EventPending

EventPending

Normally an event handler will continue processing until complete. Executing the EventPending() method allows the event to test if another event has been triggered and optionally exit the current event handler prematurely.

Note: In KCML versions prior to 6.10 build 8120 the EventPending() method checks to see if there is anything in the input stream from the client. It cannot distinguish between property values being returned from the client and events being triggered and so may return TRUE even though no event has has been triggered. If the intention of using EventPending() is to enable as a cancel option in an event that might take some considerable time, then it is recommended that you bring up a non-resizable child form with just a cancel button (and, ideally, a progress bar), so that the result of the EventPending() method is unambiguous.

DEFFORM Form1()={.form,.Form$,.Style=0x50c000c4,.Width=208,.Height=50,.Text$="Check",.Id=1024},\
{.Ok,.button$,.Style=0x50010001,.Left=154,.Top=4,.Width=50,.Height=14,.Text$="OK",.__Anchor=5,.Id=1,.Click()#},\
{.cancel,.button$,.Style=0x50010000,.Left=154,.Top=20,.Width=50,.Height=14,.Text$="Cancel",.__Anchor=5,.Id=2}
DEFEVENT Form1.Ok.Click()
	Form2.Open()
END EVENT
FORM END
DEFFORM Form2()={.form,.Form$,.Style=0x50c000c4,.Width=208,.Height=53,.Text$="Form2",.Id=1024,.Show()#},\
{.cancel,.button$,.Style=0x50010000,.Left=154,.Top=4,.Width=50,.Height=14,.Text$="Cancel",.__Anchor=5,.Id=2},\
{.gauge,.kcmlgauge$,.Style=0x50010000,.Left=-2,.Top=31,.Width=212,.Height=14,.Id=1000,.Range=100}
LOCAL DIM count, maxrecords = 5000000
DEFEVENT Form2.Show()
	.gauge.Range = maxrecords
	WHILE (++count < maxrecords) DO
		.gauge.Position = count
		IF (MOD(count, 1000) == 0) THEN .form.Flush()
		IF (.form.EventPending())
			BREAK
		END IF
	WEND
END EVENT
FORM END
Form1.Open()

See also

Form methods, properties and events.