Qt - How to force the drop action to be copyaction when the drop location is some other application - qt

I have subclassed QMimeData and drag&drop works perfectly fine within my widget – for both copyAction and MoveAction, Data gets copied and moved as needed (based on shift / ctrl keys etc.)
For compatibility I am supporting other simple formats such as text/plain – the major problem is, I cannot allow ‘move’ operation for the drops to other applications for these compatible formats.
For example, I allow my data to be dropped from my widget to some textbox – but only as long as it is a ‘copyAction’. But, I do not see any way of forcing this.
Question: How to force the drop action to be ‘copy action’ for all external widgets, while allowing the copy/move within my widget?????
By 'force' it is meant no matter what user chooses (ctrl, shift or whatever) - my data should always get 'copied' and not 'moved' when the drag happens for compatible formats. (while it should allow copy and move for its native format)
How to enforce this in Qt?

This appears to be a limitation in Qt.
This post describes the issue and shows that the problem is in QAbstractItemView::startDrag().
Essentially, Qt doesn't directly let you drag both internally to the same widget, and to an external application.

Related

Links inside of a Xamarin.Forms/Xamarin.Android WebView won't work

I have a Xamarin.Forms app that opens locally saved HTML files which contain relative link to each other (think an old HTML offline docs) in a WebView. Everything functioned in Android 10, but now I needed to make a custom renderer in Xamarin.Android due to the new Android 11 changes needing AllowFileAccess (I have all accesses currently on for testing until I get this problem fixed) in the WebSettings. The WebView's OnElementChange sets all the Control's settings, sets the WebClient (which has a ShouldOverrideUrlLoading set to handle particular filetypes like PDF), and then loads the URL. The first page loads fine, but none of the links operate (this testing page has a few links to other HTML pages and some to PDFs). Click on the highlights them as normal, but nothing opens.
No breakpoints in the WebClient's ShouldOverride are hit and neither are any in the Android WebView's OnElementChanged when I click a link. The output window registers the touch, but doesn't do anything more. I feel like this is some kind of communication problem between Xamarin.Forms WebView and Xamarin.Android WebView (possibly even the Xamarin.Android's WebView not being up to date with Android's WebView), but I do not know where to look. Has anyone run into a similar situation and have a fix to get the links functioning again?
Thanks.
After much blood, sweat, and tears, mostly tears, I found the solution.
First off, WebView doesn't tell you directly, but anything that targets a new window (IE _blank and potentially others) will not hit your WebViewClient's ShouldOverrideUrlLoading method and instead hit your WebViewChromeClient's OnCreateWindow method. So you need to handle loading through that one as well as through your WebViewClient.
Second, links will not always work because of Safe Browsing in the WebView. Again, Google doesn't specifically say it can cause issues with urls, but it works against outside urls (which in a file is potentially every url). I had to turn it off, which you can find instructions at developer.android.com/guide/webapps/managing-webview, and I was able to navigate just fine. I feel you will want to set up safeguards to prevent people from abusing your app (like having a WebView that is for your stuff with Safe Browsing off and another for all others, or blocking any sites that aren't yours) since cybersecurity is always a thing.
Lastly, I found IFrames won't load properly if you manually load the page in the view passed to WebViewClient's ShouldOverrideUrlLoading. The sizing goes all off in my docs, which leads me to believe the elves in the background do something special if you return false and the WebView handles it. I found I needed to handle all my other cases (IE pdfs, images, etc) and then return false from ShouldOverrideUrlLoading if it is my iframe htmls.
As a note, because I had forgotten this having worked on Windows for so long, remember that Android's base file system is case sensitive, which makes links case sensitive. You need to either makes sure all your casing is correct in your files or have them on a FAT file system SD card if you want them to be insensitive.

Accessibility - provide mechanism for easy navigation between interactive sections

We have a web-based app which uses a side-by-side experience for desktop users where the left side of the screen is a file browser and editor and the right side of the screen is an interactive preview. Users of our app will make constant and iterative changes on the left and and then interact with the preview on the right, switching back and forth many times in quick succession.
Is there a "best practice" for allowing quick and easy navigation between these two interactive areas? I know this might fall under the "opinion" category, but I feel that accessibility is such an overlooked topic that it helps to have as many resources as possible.
You have a few tools at your disposal.
Headings
Headings are one of the easiest ways to bake in some super simple section switching. Screen reader users will use the keys 1 through 6 to navigate by heading levels so if both of your panels are <h2>s (for example) they can simply cycle location using headings.
Keyboard shortcut keys
You can set keyboard shortcut keys.
However you should never do this in isolation. By this I mean if you say that switching window is say Alt + 0 you must allow users to be able to change these key bindings to their preferences.
This is so your shortcut keys don't interfere with their screen reader keys (as they may have set custom keyboard shortcuts).
please note: as pointed out in the comments this is not a WCAG requirement for key combinations (which is only for single keys) but is a usability best practice and highly encouraged, especially as some screen reader users use a modifier key rather than a toggle key for screen reader navigation.
Then we get into an interesting area which I like to illustrate by saying "how would a one handed user use your page?".
This example makes you realise that some sort of sticky keys solution may also be considered where key combinations can be done with a sequence of keys, any time apart (as you may have someone with NO HANDS using eye gaze technology or a switch for example so you don't want to impose a time limit.)
Obviously the above are extreme examples but things you may want to consider (and in reality anyone using eye gaze would be able to visually switch panels etc.)
Voice commands
Being able to switch panels via voice (for example Dragon Naturally Speaking) is also essential.
Now you can do key combinations with voice software so that fixes most issues but they can be annoying and fiddly.
One thing that is quick to use on most voice software is clicking any button on a page with a unique name.
As such having a button above each panel that activates it would be beneficial to voice users.
Assuming these buttons have unique names I could simply say "click activate panel 2" (where "activate panel 2" is the button name) and switch immediately.
Do you need to manage focus?
Bear in mind that when you switch panels you will by default start at the top each time.
This may be exactly what you want but more than likely this would be a terrible user experience.
Instead you may want to remember the previous focus location. Then if I use the keyboard shortcut it would jump back to the same location in the panel. If I use the voice / button click to change location same again.
However if someone uses headings to navigate this obviously wouldn't work. You could then give them a button directly after the heading that says "resume from previous location" to fix this and use that to manage focus.
User settings
As you can see there are loads of things that different people with different requirements may or may not need.
As such adding all of the features by default would probably make the application worse to use for majority of users.
Instead have a settings screen that lets a user turn on features that benefit them, set their own shortcut keys, turn on or off sticky keys, decide if they want you to manage focus for them (or not) etc.
This is a difficult problem! I have been giving a similar issue a lot of thought. I have outlined one idea that uses ARIA live regions, and an alternative idea that might work better if quick-jump keyboard support is vital.
Live region announcements as part of a <form>
The <output> tag may be what you're looking for. It is mapped to the ARIA role of status so any changes to its content will be announced without any focus change. That way, the user can continue to navigate and make changes on the left side without always having to flip over to the right side to know what changes were made.
The role status has an implicit aria-live value of "polite", so that the announcement will wait until any other descriptive announcement is finished.
It has an implicit aria-atomic value of "true", which means that any change will trigger the announcement of the entire contents of the element -- which may or may not be appropriate for the content. If not, add aria-atomic="false" to read out only the changed node.
If the content inside the <output> could be anything other than phrasing content (including <div>s or heading tags) then you should use a <div> with the role attribute of "status" instead.
Custom keyboard controls can get tricky with various types of assistive technology (AT) software/hardware. Plus those commands probably can't be made easily discoverable. Some ATs provide a keyboard command to flip between a controlling element and the element assigned via its aria-controls attribute. Unfortunately, this functionality is poorly supported, but it is the current standard, so support may get better over time. Currently only NVDA on Windows supports it, with the keyboard command Insert + Alt + M.
Adding aria-controls to an element controlling an <output>/status is mandatory anyway, so give it a unique id attribute and set that as the value of aria-controls on each form element inside the <form>.
If the <output>/status is wrapped in a <fieldset> and the inputs are all wrapped in a containing <fieldset>, then each <fieldset> acts as a grouping container, so the user can navigate between them quickly. As part of this, ensure the <fieldset> containing the <output> directly follows <fieldset> containing the form elements in the source order. If this isn't possible, add the aria-owns attribute to the containing <form> and reference the id attributes of both <fieldset>s with a space in between.
Always-open non-modal <dialog>
You may instead consider making the right side pane an always-open non-modal <dialog>. A <button> next to each interactive element on the left pane would move focus to the <dialog>, and the Escape key would return focus back to the <button>. Focus isn't trapped within a non-modal <dialog>, so the user can still move between each pane using normal navigation methods. The <dialog> needs to have an open attribute to appear and it also needs to have aria-modal="false".
Each <button> would need an aria-controls value referencing the <dialog>'s id attribute, and an aria-haspopup value of "dialog". The <button>s could be invisible until focused.
There's only a single focused point at any given time. So there isn't any real miracle solution, screen reader and other keyboard-only users will necessarily have to repeatedly go back and forth.
IN fact, the most important isn't to be able to switch quickly between the different parts (you must only somehow give a way to do it only with keyboard), but to not lose cursor position when you switch.
For example if I edit something on the left, go to the right to check the result, and then go back to the left side, I expect to find the insertion point exactly where I left it off.
You really have to make sure that this is always correct, and as closest as possible when changes occurs (especially when it's asynchronous, i.e. a change occurs on the right side when you are on the left side).
The most similar accessibility recipe or component is probably split view.
In windows world, the most used shortcuts for cycling between the different splitte parts is F6, and Shift+F6 to cycle in reverse direction.
Don't hesitate to add other easier or additional shortcuts if the switch has to be really frequent, such as Ctrl+Tab, if such shortcuts aren't already used for something else.
F6 and Shift+F6 aren't the easiest shortcuts to perform, especially on laptops where all F1-12 keys may not be available at all or only by using an additional FN key. I personally always found F6 a questionnable choice, but that's only an opinion; at least we have something and that's of course better than nothing.
However, don't replace an existing shortcut commonly used. (for example Ctrl+Tab = switch between different tabs, don't use it for cycling between views if there are tabs in your application and keep it for the tabs)

AutoHotKey to focus a Form in Microsoft Access 2010/2013

I would like to use AutoHotKey to bring an access database to the screen, then take focus on one form (the form is open, but there will always be multiple other forms open at the same time, additionally, the form in question could be stacked at the bottom) and then the rest can be done with custom shortcuts that only work in this form.
I am also open for other solutions to do the same job, mouse clicks is also a possibility but forms are not always in the same place on different computers and they can also be moved during a session.
This is what I have been testing so far:
Bring up the database with IfWinExist, [title of window]
Then I tried using ControlFocus, [ControllerName]
That did work, but the controllername changes depending on what other forms are open and in which order they where last clicked on.
I have made a screenshot:
Any help would be nice, my main problem is that I do not know what AHK can do and therefore I feel very limited.
In the place of WinTitle you can also use other parameters of the window, not only WinTitle. More about it here: http://ahkscript.org/docs/misc/WinTitle.htm
Also you can use ImageSearch to get coordinates of the window and use these coordinates to move window without WinMove like here: http://ahkscript.org/boards/viewtopic.php?f=6&t=4013

Coded UI Testing in IE - How to upload a file?

With our CUIT tests in Visual Studio we have the problem that we cannot record the Browser Button action in IE. We just get:
C:\fakepath\Document1.txt
But this obviously does not lead to the real document in a playback. And it's not possible to just type the path into the Browse text field anymore.
Just FYI: This applies to the Coded UI Testing Framework in Visual Studio 2010 Feature Pack 2. The recorder only works with IE.
Any ideas?
Not being able to access the file upload control is supposed to be a security feature. I guess you need to step out of your environment and into the windows environment to accomplish anything.
If you use a macro recorder that can playback from command line (like http://www.jitbit.com/macro-recorder/versionhistory/) or a similar means, you may be able to record the missing step here (like a simple tab key hit - provided you have focused on the control before the upload control -, a typed text, and another tab key hit) and start the resulting "batch". Or you can even record a mouse click.
However, if this test runs in other browsers (if I understand you correctly), wouldn't it be safe enough to assume that it runs in IE as well, because after all you are using a standard control?
Actually, turns out I can edit the value "C:\fakepath\Document1.txt" manually in the uitest UIMaps file and change it to a real path. And it works in the reply like this.

Force system cursor usage in Flex

Let's say that you're using some black box library (i.e. no source code) that sets your cursor to something when rolling over a certain sprite. You can override that by catching rollOver and rollOut events, blocking propagation and using the CursorManager.
Question: is there a way to tell the CursorManager to use the system cursor?
Obviously, I could feed the CursorManager some "system like" cursor, but this would look weird if the local settings are different from that icon, which is likely to be always.
thank you!
f
You can create your own version of CursorManager - just create file mx/managers/CursorManager.as, copy it's content from default manager (use Ctrl+Shift+T to navigate to it) and change the code.
If you use RSLs then you need to create monkey-patch and load it BEFORE RSLs.
if you embed SDK into code then you can simply compile the app and class will be replaced.

Resources