How Do I Interrupt a Find Dialog in Delphi? - delphi

I have a standard Find Dialog:
My program can process some very large files, and finding text in such files may take 10 or 20 seconds or more. So after the "Find Next" button is pressed, I change the cursor to an hourglass. I change it back to the standard pointer after the text is either found or not found.
My problem is that the user may decide to cancel the search and decide to do so by pressing the Cancel button. The Cancel button then closes the dialog but the search continues within my FindDialogFind routine until the text is either found or not found.
I've put a breakpoint upon exit from the FindDialog.exe, but it is not reached until the FindDialogFind is completed.
Is there any way I can capture the fact that the Cancel button has been pressed which will allow me to break the FindDialogFind loop, or maybe is there some better way to stop the search when the Cancel button is pressed?

In the OnCloseevent of the TFindDialog component, set a boolean variable, FAbortSearch.
Check this var often in your search routine, and abort if set.

Move the searching logic into a worker thread that you launch whenever the Next button is pressed. When the dialog is closed, you can terminate the thread if it is still running.

Related

Is there any way I can get notified when user trigger the system default long press behavior in WKWebView?

I know how to disable system default long press behavior by evaluate this script document.body.style.webkitTouchCallout='none'.
There's such a requirement. When users long press an image and click the "save to album" popup button, I need to be notified and give a response.
Is there any good way (not a hack) I can achieve this?
Or I should make a custom native interface and disable the default long press behavior?

Ranorex v5.0 doesn’t click button sporadical

I have a ranorex project, which automated an use case with clicking 5 buttons in an application.
To set up this project I used the record function. I defined some sleep times between the clicks.
The run with the clicks is in a loop, where the loop count is dynamically defined. One button of the five and always the same button, Ranorex "ignores" sometimes. According to the log file, the button is visible and enabled and ranorex also runs the code with the Click(), but the application doesn’t receive the click. Before in code the click is called, I check with an “If” whether the button is visible and enabled - and if the click() is called (or doesn't), I log it to ranorexlog. Sometimes the application is running through and all the clicks work and sometimes this button click is missing one or more times. It doesn’t depend on the sleep time between the clicks, because I tried long and small pause times. It doesn’t depend on the focus of the application, too, because I switched the focus several times.
Does anybody know this problem, workarounds or what I’m doing wrong?
the obvious workaround is to use Mouse.Click("{Button}") with a 0 duration rather than invoking the click event, or if you are invoking the mouse click invoke the buttons click action. (sorry since they are both named Click() i don't know which one you are using).
As to what is happening, from your description it sounds like your script is finding more than one element with the same xpath. This would cause issues with the click event because it may try to click on the element, but it's the first xpath that matches not the second. Are there any optional elements in this sequence of button clicks that appear? for instance a busy spinner with inner text of "OK" that is hidden from view when you are clicking a button on a form with inner text of "OK" would cause two elements to be found if the xpath was looking for an inner text of ok. This element that is causing may not have been caught in the recorder because it might not have been present at the time.
Another possibility if you are using Mouse.Click() (particularly if this is a website)is that it is possible your button is not actually on the screen, I know that should be taken care of by the visible check but it is visible on the dom even though it is not visible on the screen that causes issues.
I highly recommend do not use the recorder to create test suites that need to be re-runnable. It would actually be better to use the spy tool to create a repository or several repositories for the product you are testing, this way you can be sure the xpaths are all unique, which using the recorder there is no gaurantee. You can actually record with the created repository, and ranorex will attempt to find item in the repository before creating a new item, so the recorder will use this repository when creating recordings.

How to keep soft keyboard opened on iOS. Flash Builder 4

I'm building chat application for mobile devices with Adobe Flash Builder 4.6.
I have s:TextInput for message entering and s:Button for sending message.
When user enters message and taps "Send" keyboard goes down. I want to keep it opened.
I can use textInput.setFocus() and setFocus with setTimeout(), but it gives unexpected results sometimes. For example soft keyboard can jump or goes down without resizing stage.
Could you recommend good solution for keeping soft keyboard opened when taping outside text input (focus should left in text input).
What worked for me was:
Create a listener for the TextInput focus out event
Put textInput.setFocus() code in that listener handler
When I want the textInput to be able to focus out for specific cases I create a lockFocus variable for the listener to check first before deciding to reassign focus or not.
Hope that helps!

How to close a prompt form or dialogue upon a hardware event?

I want to prompt the user to scan a bar code or RFID tag. That (I guess) means either MessageDlg() or a small form - I don't care which and invite advice.
When I read a scan over serial port or HID (or timer or WM_xxxx), I want to close that prompt.
What is the simplest way to go about that? Thankls
We have this feature in our application with even 1 more integrated step to start with.
I will describe it fully, as it might be useful to you.
We have a modal dialog that allows the user to enter the Serial Id for a device by either keying it in with the keyboard or just scanning the barcode tag.
Step 1. We have a menu item with a Hot Key (Shortcut Ctrl+Alt+N for instance). We have configured the scanner so that it sends this preamble whenever it scans a barcode. (Manual equivalent of keying in the shortcut). That opens the modal dialog.
Step 2. The Focus is in a Edit box to get the Serial ID either from the user and the keyboard or from the scanner reading the barcode.
Step 3. There are an [OK] and a [Cancel] buttons. The OK button has Default:=True and ModalResult:=mrOK. The Cancel button has Cancel:=True and ModalResult:=mrCancel. The scanner is set to postfix the scanned string with Enter which has the same effect as the user hitting the [Enter] key or clicking the OK button: it closes the modal dialog with mrOK in the ModalResult so we can read the Edit.text to get the SerialID.
Step 3bis. The user presses [Esc] or click on Cancel or closes the dialog with the title bar close button: it closes the dialog with anything but mrOK and we discard whatever is in the Edit...
Works very well in our case with any scanner working as an HID emulation (keyboard) and where we can configure the preamble. (sending Enter at the end was by default in all the scanners we tried).
You can create a form, making it without border and title (or no close button) and stayontop and add in your message or animation or anything. If applicable, it is best to give a cancel button for the user to cancel the operation.
You can create the form the first time you use it and check for Assigned to free it on your parent form close.
Then when you need the user to scan card (or the like), just
Lock your parent form for other input then the those you expected,
show the form (not showmodel) and loop / wait for the event in your parent form.
You can still process other functionality if needed, but be very careful as unexpected action might mess up the operation.
when condition met (success scan or canceled or time out, etc), hide the child form
unlock your parent form and proceed.

How to get the mouse button state in Silverlight outside of button press events?

I have the following situation
I handle when the left mouse button is pressed in my Silverlight app and do some things while the mouse is held down and the mouse moves. When the left button is released, I turn off the flag that's telling it to do the stuff and the mouse movement handler then no longer does the stuff.
The problem is: if the user is in the control area, pushes the left button down and moves out of the control area, then releases the button and reenters, the MouseLeftButtonUp event never fires and the processing continues until the user clicks the mouse.
My temporary fix was to turn the mouse flag off on MouseLeave but that's not really what I'm going for. I'd like to check to see the mouse's left button state in the MouseEnter event, but I don't know of a way to do that.
Does anyone know of a way I can access the mouse button state outside of the press events in Silverlight 3? Thanks,
Update
After thorough research, it doesn't look like this is possible in Silverlight 2 (and probably 3.) I found this link. If anyone knows of a workaround, please let me know.
What you need to do can be accomplished with the UIElement.CaptureMouse method:
http://msdn.microsoft.com/en-us/library/system.windows.uielement.capturemouse%28VS.95%29.aspx
When a UIElement has captured the mouse, it will continue to receive mouse events even if the mouse leaves the Silverlight control.

Resources