PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → TableInputSearch - closing the input field
TableInputSearch - closing the input field
Iniciado por guest, 10,sep. 2017 13:08 - 1 respuesta
Publicado el 10,septiembre 2017 - 13:08
Hi,

has any of you a working solution to close the input field after it has lost focus?

Unfortunately, it's not the same "FOCUS lost" as of the Table itself. I simply believe that they either forgot to automatically close the search field on 'focus lost' (= cursor went somewhere else) or forgot to provide a Table-function for closing that field.
Publicado el 11,septiembre 2017 - 08:06
Hi, to close the Edit Control in the Column's Header took me a day of fiddling around.

The desired mechanism mimics the sequence of keystrokes of another program:

The user wants to search for a certain customer by customer number and switch to display said customer on screen ..

1 - user inputs a non-numeric code (e.g. "K") in the Edit Control below. Essential part of the code:

TableSort(MyTable,"CustomerNumber") // searching needs the appropriate sort sequence
TableInputSearch(MyTable.CustomerNumber,searchDefault) // open the Search Edit Control
ReturnToCapture(MyTable.CustomerNumber) // put cursor into the Search Edit Control (maybe, that's a bug or a feature, who knows?)

This will open the Edit Control in the Header of table column "Customer Number" and make it ready for input.

2 - Now, the user is able to either directly input a desired customer number and/or scroll up/down by using the arrow-up and arrow-down. Whenever the selection bar is over the desired customer, the user will hit the RETURN key. The idea is to a) display the customer's address etc. and b) to close the Search Edit Control and c) to return to the Edit Control below.

Since the Search Edit Control doesn't simply close when leaving MyTable, we have to simulate a click of the selection bar over the selected customer in MyTable.

in event Key down (WM_KEYDOWN) of MyTable:

IF _EVE.wParam = 13 THEN // user pressed the RETURN key. ROWSELECTED = true // window's init code: ROWSELECTED is boolean = False hwnd = Handle(MyTable) // in the window's init code: hwnd is system int ACTUAL_CUSTNUMBER = MyTable.CustomerNumber // do all the display and selection things here // move the selected customer row to the topmost row of the Table, certainly there are several ways, I do it by // TableSeeking the row CustomerNumber MyPosition = TableSeek(CustomerNumber,ACTUAL_CUSTNUMBER) // window's init code: MyPosition is 4-byte int IF MyPosition > 0 THEN TableSelectPlus(MyTable, MyPosition) // The selected row becomes the topmost PostMessage(hwnd,WM_LBUTTONDOWN,20,20) // this "clicks" the topmost row and closes the Search Edit Control! // note: after the simulated "click" code continues at event "Selecting a row of MyTable". // variable ROWSELECTED will assist in distinguishing between a simple click and theRETURN key END