Kivy 1.10. Close the keyboard when TextInput is not selected - python-2.7

I have multiple TextInputs.
Each time I click on a TextInput, a keyboard pops up.
I don't want multiple keyboards to pop up. What I want is to have just one keyboard on the screen (corresponding to selected TextInput). I am using "systemandmulti" mode but do not want "docked" mode.
So, I want a floating keyboard but just one and not multiple keyboards simultaneously on one screen.
multiple keyboards not needed or recommended for my use
Is it possible?

Related

How to minimize screen flickering when carrying out multiple graphic changes in Qt?

I am implementing fullscreen function (and restore) in my application, which will hide toolbars, few other qt widgets to show a single window in fullscreen. For the same I pass individual high level commands to hide/show each item. But as qt processes each I see multiple intermediate screens. I am looking out for command to make the process smooth and avoid seeing intermediate visuals. Currently I am hiding the main window completely and display it back after all modifications are complete but not satisfied as the application disappears for 2-3 seconds.
I am looking for some solution to avoid display of multiple intermediate screens making transition more smooth.
You should be able achieve this using updatesEnabled property of QWidget.
Disable updates for the widget which contains all the child widgets and layouts you want updated (it might be your top level window, or perhaps QMainWindow central widget, or whatever), do the changes, then re-enable updates.

How to programmatically select text in a console application?

I can't seem to find how to select text in my console application via WinAPI. Pretty much what could be done with the mouse, if someone right-clicks the console window and selects "Mark":
and then drags the mouse on the console window:
Can I do this with WinAPIs?
There is no API to do what you are asking for. So you will have to simulate it instead.
Use SetConsoleMode() to enable the ENABLE_QUICK_EDIT_MODE to enable selecting text with the mouse. Then use SendInput() or mouse_event() to manipulate mouse movement and clicks as needed.
Use GetConsoleWindow() to get the console's HWND, and GetWindowRect() to get its position onscreen. Use GetConsoleScreenBufferInfo/Ex() to get the column/row counts of the console, and the rectangle where the characters appear within the console window. Then you should be able to use some math to translate character column/row offsets into screen coordinates as needed when sending mouse actions.
Use ReadConsoleOutput to read the area that you want to select. Change the received CHAR_INFO Attributes for each character to reflect different (e.g. inverted) colours. Use WriteConsoleOutput to write the modified data to the same rectangular area. This will show a 'selected' area. If needed use SetConsoleCursorPosition to change the cursor position. An example how to use the ReadConsoleOutput and WriteConsoleOutput can be seen here.

C++ WinAPI - How to make button appear pressed?

I have in my editor few editing modes. I can choose specific mode using buttons that are placed on a toolbar. I want to indicate which mode is currently on. When I press appropriate button - I want to make the clicked button remain pushed. How do I do that in WinAPI? My toolbar uses bitmaps for icons if that's relevant.
There used to be a way to get something like the look and feel of a toolbar by using a normal check box with the BS_PUSHLIKE style set. But that got broken a bit with Windows XP because of mouse hover effects, so it's not widely used any more.
If you want to create your own toolbar, without the help of MFC, there is an MSDN article that covers the creation and management of a toolbar window (actually a dedicated window class as part of the Common Controls Library).

Keyboard focus: looking for a general strategy

My application has a big graphics area with some controls (sliders, buttons, text edit controls) in a side panel. The graphics area understands some keyboard commands.
My problem is that when a control in the side panel is in focus, the main graphics area won't receive any keyboard commands, so this confuses the users. However, for some controls, this is intended, e.g. text edit controls.
What I want is the focus to automatically return to the graphics area at the earliest possible occasion (which I call "greedy" focus) -- e.g. when text editing is finished (Enter key), or when the user has selected an item from a combo box.
I am looking for a clean and robust strategy for dealing with the problem, either using Windows API or Borland Vcl.
I'd appreciate if you want to share your ideas.
I haven't fully solved the problem yet, but a very useful message to intercept on form level is CM_DIALOGKEY (Borland Vcl only). It gets sent for every key that is normally used for navigating within the UI. That is, cursor keys, tab and shift-tab, Enter and possibly others.
I've added an event handler for CM_DIALOGKEY that returns the focus to the graphics area and also forwards the key press to that component. This way the user can still control the UI elements via keyboard (important for text entry), but cursor keys are handled by the graphics area.
I know what you mean I had similar problem with some BIG apps lice CAD/CAM ...
My solution is simple, robust and I use it for years.
1.all keystrokes handling for that gfx area
must be done in events of the Form where the area is located
not in panels,paint box whatever...
2.create unfocus function (preferably member of form but it is not required)
this function will loose focus of any VCL item
so the focus goes to form itself which is what you want
I am using this:
//---------------------------------------------------------------------------
void main_unfocus()
{
Main->bt_unfocus->Visible=true;
Main->bt_unfocus->SetFocus();
Main->bt_unfocus->Visible=false;
}
//---------------------------------------------------------------------------
Main is the Form pointer
bt_unfocus is button (can be any focusable VCL component)
I place this button usually on the left upper corner of App and set its size to 2x2 pixels
it is invisible at start
the idea is to set focus to it (but first unhide it so no exception is thrown)
and then hide it so it loses focus
work well in BCB5 and BDS2006 (did not used it with any other IDE)
as you can see most of the time is this component invisible
4.now when to call main_unfocus ?
when you go with mouse from outside to inside of your gfx area (OnMouseMove event)
or when you click on it
also you can combine this with remembering if the focus is or not in gfx area
that can be done with events like OnExit ...
or when you hit Esc while focus is inside edit box ...\
I am sure you grasp the idea and adjust this to your needs
Hope it helps

How to handle "switch from" and "switch to" events in X11?

I'm making a fullscreen OpenGL application, and I want it to restore original desktop mode when user switches away from it, and to restore mode back when user switches to it.
This looks like "FocusIn" and "FocusOut" events, but they are not suitable for this. Window will get "FocusOut" as soon as user presses Alt+Tab and window selector appears (because my window is loosing focus at this moment).