SeraField, close searching

Good evening group, how do you intercept the X that closes the search in SearFiled? I tried to insert if me.text="" then in textChanched() but it doesn’t work..

Why do you think you need to do that ?

The SearchField stays open. Click in the x just delete the search string (as you think).

CLick in magnifying glass icon or Return/Enter activate another search.

Hide the SearchField if that is what you want to do.

With pressed event maybe?:

How is it not working for you? Does the event not get fired or something else?

I do this in one of my projects (Windows) and it works without issue.

1 Like

Can you define, ‘it doesn’t work’
It is working here (same as Indy G):

Edit: are you on Mac, Windows or Linux? Not sure if that makes a difference.

I had a textfield, where I entered a name and searched for it via a function, when I pressed ENTER. Now I’m trying to replace the textfield with a searchFiled. As I type, it filters all the results … but if I press the X to close the search it’s as if it doesn’t understand that I stopped searching. Anyway, if I can later I’ll try to do some more tests and I’ll update you. In the meantime, thanks.

I confirm… if I do a search, I press the X, the magnifying glass reappears, but it doesn’t capture the event.
i’m work in Windows

Looks like it works different than macOS.
Do you want to create an Issue for this?

In the PRESSED event I am struck by the closure of the search. Why? Can you explain the logic to me? Thanks.

I’m sorry, language barrier. I don’t understand what you are asking.

On macOS if you click the X the pressed event fires.

I thought that the key press was captured in the TextChanged event of the SearField, and I didn’t understand how to reset my search because pressing the X didn’t activate my ListBox cleaning function. Then, following your advice, I went to explore the Pressed event, with which I realized that it doesn’t take into account the keys pressed for a possible search, but captures both the X to close the search and the enter key. So I inserted my procedure for cleaning the listbox here. Now I would like to understand how to distinguish the pressing of the enter key from the pressing of the X to end the search, since no parameter is passed.

X will always be text “” with enter. As it doesn’t make any difference if someone tries to search (pressing Enter) with empty field as pressing the X, I’m not sure why is needed to know when the enter is pressed and when the X on an empty search.

All other searches that are not empty you are sure that Enter was pressed.