XSample49()

This forum is for eXpress++ general support.
Post Reply
Message
Author
mzipkin
Posts: 15
Joined: Thu May 13, 2010 8:27 pm

XSample49()

#1 Post by mzipkin »

I'm attempting to build a data entry browse based on XSample_49(), an array editor using DCBROWSE, DCBROWSECOL and DCGETs to implement the editing. (exp20\samples\xdemo\xsample2.prg)

But I want to Append a new row to the browse when the last field of each row is successfully VALIDated.

I expected this to be trivial using PostAppEvent(xbeP_Keyboard,xbeK_ALT_A,,oBrowse)
within the VALID function at line 971.

i.e. within _XSample49() the existing code is:

ELSEIF nAction = 4 // Validate field decimals

IF cFieldType $ 'cCdDlLmM'
aStructure[nPointer,4] := 0
ELSEIF nFieldDec > nFieldLen - 2
DC_WinAlert('Decimals cannot be greater than ' + ;
Str(nFieldLen-2))
RETURN .f.
ENDIF

// I've added the following line here:
PostAppEvent(xbeP_Keyboard,xbeK_ALT_A,,oBrowse) // <- force new row to be added to browse

ELSEIF nAction = 5
...

However no row is appended to the browse when expected, and:
1) the event viewer never shows the event as being received, but
2) the postappevent() returns .T.

A related observation is that the EVAL clause of the DCBROWSE does not seem to be performing it's intended function of adding a row when the browse cursor hits the bottom of the browse (except once, when the browse first opens):
EVAL {|o|o:hitBottomBlock := {||PostAppEvent(xbeP_Keyboard,xbeK_ALT_A,,oBrowse)} }

So, what am I missing? Shouldn't the PostAppEvent cause a row to be added to the browse?

Using 19SL1, Express++ build 20267, Win10

Many thanks,

Mark

mzipkin
Posts: 15
Joined: Thu May 13, 2010 8:27 pm

Re: XSample49()

#2 Post by mzipkin »

Update:

The cell editors are implemented by DC_BrowCellEdit() in _DCGETBX.prg. Because this function clears events just before exiting, any events created in the GET/VALID block are discarded.

One approach is to post the event after DC_BrowCellEdit() exits by making the following call in the valid codeblock of the cell editor:
SetTimerEvent(10, {|| PostAppEvent(xbeP_Keyboard,xbeK_ALT_A,,oBrowse), SetTimerEvent(0) } )

...but it's an ugly kludge and, more importantly, is not 100% reliable.

Can anyone suggest an approach which doesn't depend on a timer?

Many thanks,

Mark

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: XSample49()

#3 Post by rdonnay »

I don't know if this will help.

Look at line 336 of the attached program.
Attachments
test.zip
(3.38 KiB) Downloaded 351 times
The eXpress train is coming - and it has more cars.

mzipkin
Posts: 15
Joined: Thu May 13, 2010 8:27 pm

Re: XSample49()

#4 Post by mzipkin »

Roger, thanks for your reply.

The test program will add a new row to the browse only if the following steps occur beforehand:
Navigate to the last column of the last row and press Enter to enter edit mode, then press Enter again to exit edit mode. i.e. it will perform the same function as ALT_A.

However, it does not work after entering data in the cells of a newly *added* row. My intent is for the browse to continue to add new rows after each new row has been fully populated with data by the user.

Any other ideas?

Many thanks,

Mark

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: XSample49()

#5 Post by rdonnay »

Remove the call to DC_ClearEvents() on line 36.
This is preventing the PostAppEvent() call from working properly.
The eXpress train is coming - and it has more cars.

mzipkin
Posts: 15
Joined: Thu May 13, 2010 8:27 pm

Re: XSample49()

#6 Post by mzipkin »

Roger,

Thank you *very* much. That did the trick!

Regards,

'Mark

Post Reply