Is there a signal that is sent by QTextBrowser when highlighting text?
self.textBrowser.highlighted.connect(self.test)
def test(self,argv_1):
print('This Worked')
When I tried this the signal didn't seem to be sent.
The highlighted signal is emitted when an anchor in the text is highlighted, it doesn't fire when text is selected.
If you're interested in in changes of the selection, use the selectionChanged signal (inherited from QTextEdit)
Related
When I start up my PyQt GUI, the focus immediately goes to the text box.
I want there to be no focus on any of the buttons at the start of the program, especially not the text box.
Is there a way to remove the focus entirely or at least move the focus to a button or something?
Thanks
clearFocus() seems to work after a certain amount of delay after the window is visible. I also used setFocus() on the QMainWindow and then the textedit field lost focus.
Create a button with dimensions 0 wide by 0 high.
Set it as the default button and also early in the tab order before the other controlls that except focus; but note that it will be triggered if the user presses ENTER in some edit controls.
Call self.ui.yourbutton.setFocus() if desired for example after restore from minimized
I'm new to codename one and try to set the foreground (text) color of a TextView. Setting it to red color and writing a text after pressing a button works. The code is executed in button's action listener method:
mValueField.getStyle().setFgColor(0xFF0000); // set red color
mValueField.setText("Fill in!"); // write info text
After setting focus into the field the text should disappear and color should be black again. The code is executed in TextField's focusGained() method:
mValueField.setText(""); // clear info text
mValueField.getStyle().setFgColor(0x000000); // set black color
Problem is that the text disappears but new chars are still red instead of black.
Any solutions for me?
Don't use getStyle() it's designed for use within paint() or similar methods. Since the component has multiple states you need to customize every individual state e.g. getUnselectedStyle(), getSelectedStyle() etc.
Or you can use the getAllStyles() to set them all with a single call.
It is possible to read the following in the apple Documentation:
UIKeyboardFrameBeginUserInfoKey
The key for an NSValue object containing a CGRect that identifies the start frame of the keyboard ……
UIKeyboardFrameEndUserInfoKey
The key for an NSValue object containing a CGRect that identifies the end frame of the keyboard ……
Would that mean that the keyboard has a "start frame" and an "end frame"?
I suppose YES.
But when the keyboard appears I cannot see any frame changing. It just stays the same frome start to end.
So my question is:
What are those "start frame" and "end frame" referring to?
I must be missing something.
Thanks for your help.
The keyboard does indeed have a start and end frame, and the properties do exactly what you suppose they do. They keyboard does not always animate however; sometimes it just appears or changes size. For example, in the case that you are typing on the Japanese keyboard, when the keyboardWillShow fires after the first character is hit. There's no animation, but an additional bar appears above the keyboard, thus changing the size. The properties you listed above tell you how much the keyboard changed size by.
I'm not sure what exactly you're looking at when you say no frames are changing. I suppose it's possible that when you move from one editable text field to another, you get a keyboardWillShow notification, even though nothing on the screen changes.
I am trying to automate some text field for testing purposes. I programmatically do this
[textField becomeFirstResponder]; // Keyboard pops up
[textField setText:#"sometext"]; // Some text is automatically entered into text field
[textField resignFirstResponder]; // Keyboard goes away
The keyboard will show, keyboard did show events are fired up. But when the keyboard goes away it doesn't fire keyboard will hide / keyboard did hide events.
How can I automate these events? Any ideas will be helpful.
I solved it by adding a custom button to the keyboard. Since I have pointer to that button I just did
[button sendActionsForControlEvents:UIControlEventTouchUpInside]
This actually generates keyboard will hide event first.
Then the textfield does an EndEdit event.
Then the keyboard did hide event gets fired.
if you are inactive on gmail, by not moving your mouse for a while, it changes your chat status to orange which means idle. but when you start moving the mouse again it turns it back to green meaning active. how does it know when you are moving your mouse?
without checking, I'd say this is done with an onmousemove event handler attached to the whole document.
You can attach an "onmousemove" event to the Javascript "document" object, which is triggered every time the mouse moves across the browser window. It's a simple task to reset a timer whenever this happens, and if the timer goes off without any movement detected, it will set your status to "idle". When the onmousemove function is next called, it will set your status back to "available".
Example with full code: http://www.codeguru.com/forum/archive/index.php/t-433956.html