On becomeFirstResponder Show Placeholder - text

Hi when I open up my textfield (becomeFirstResponder) it shows my text as text. How can I take the users input for that textfield (14.25) and make it a .placholder text. For example if the user puts in 14.25 in the text field when they get out and look out at the textfield it should be black like text, but when they click on the textfield again to edit it the current text (14.25) changes from .text to .placholder. Does that make sense? If it does not please let me know.
I dont really know what to do but I made a shot at it and nothing happened haha.
billAmountTextField.text = billAmountTextField.placeholder;
Thanks for your help!

Not sure to understand, but are you trying to replace the placeholder by the text, at the time you start editing? Of so, your line is in the wrong way. Try this:
billAmountTextField.placeholder = billAmountTextField.text;
Moreover, you need to clear out the text itself, if you want the placehold to show up.
billAmountTextField.text = #"";
Makes sense?

Related

Get the Text widget that is focused [tkinter]

Simple question, not sure if there is an answer.
Imagine you have 2 text boxes in a tkinter window, is it possible to know which of the 2 the user is focused on, then return the text widget object itself, or a variable that tells you something.
**Context: **Trying to insert a set of characters at the users cursor, but I want it to add it at their cursor regardless of the text box. Instead of:
self.text1.insert(tk.INSERT, "
Some text..."), I want self.focusedText.insert(tk.INSERT, "
Some text at your cursor in the focused text widget..."). Is there some way to figure out which of many Text widgets a user is focused on? Thanks!

Android Studio Widget, Text Field, Large, Medium and Small Text is missing all I have is Plain which gives a Name. How can I get it and others?

I'm looking at Youtube examples and I see the instructor has Widgets I don't have, Like different size Text Fields and an analogue clock.
Is there somewhere I can get more Widgets?
I obtained a text size same as to the "tutorial" using:
android:textAppearance="#style/TextAppearance.AppCompat.Large"
Looks like AndroidStudio has undergone some change. Best option is to enter the "Text" mode and type the style yourself. For ex. if you need an equivalent of LargeText view, then add a TextView and move onto the Text mode and add this line:
android:textAppearance="#style/?android:attr/textAppearanceLarge"
Or you could also edit the properties of TextView too.
You should add this line android:textAppearance="#android:style/TextAppearance.Large"
inside the TextView after clicking on the Text tab near Design tab located in the middle left to the right of design tab.
but you have to consider that first of all you need to drag and drop TextView from Widgets into the user interface or Design section.
Click into the Text tab located middle left to the right of the Design tab, find the TextView element and within it simply enter this line of code:
style="/?android:attr/textAppearanceLarge"
Remember this line of code has to be within the element in order for it to work.
Go to properties and then select text appearance and select app.
combat.large
Use this:
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
Add it inside your Textview tag.

Line breaks in Statusbar

I have a program here that uses the GTK Status bar and I'd like to have multi-line output in it. When I try to output multiple lines into it, I get glyphs instead as seen below:
I'd expect it to work like in emacs:
After some searching, I discovered layoutSetSingleParagraphMode which seems to do exactly what I want. The default setting is False for most widgets and we're not setting it ourselves anywhere which makes me think that Statusbar defaults to single paragraph mode.
My problem is that I have no idea how to go from Statusbar to PangoLayout upon which I can use this function.
The closest I have come was finding widgetGetPangoContext which then let me get PangoLayout with layoutEmpty but as the name suggest, this seems to just create a separate PangoLayout which doesn't affect the statusbar when manipulated: pushing or popping of text behaves as it did before this.
Is there a function I'm missing? Admittedly, gtk2hs swims in a sea of type-classes to emulate OO which doesn't contribute to the readability of the generated docs. It seems that it should be a simple task.
If we're never meant to get out a PangoLayout from existing widget then how can I achieve what I want? There seems to be no option to choose the paragraph mode at Statusbar creation time.
See this for a GitHub issue for this project relating to this.
Please try this:
Use statusbarGetMessageArea to get the Gtk.Box where the status bar's text label is.
Then get the text label with containerGetChildren <status bar message area>. This function returns a list of Gtk.Widget with just one element, the label.
Cast the widget to a label with castToLabel.
Now you can set multi line mode with labelSetSingleLineMode <label> False.
Set the label's contents with labelSetText or labelSetMarkup.
I have tried it with success (gtk 0.12.5 from Hackage, using GTK2, haven't tried it with GTK3).

Displaying text on a swt button vertically

I'm trying to display text on a button. Instead of displaying it as "Vertical", I'd like to display it as
V
e
r
t
i
c
a
l
Any assistance is much appreciated.
You have to make your own widget to achieve it in SWT.
Here is a complete example that you can try. Hope it helps.
SWT buttons do support wrapping (since 3.7).
Button button = new Button(parent, SWT.PUSH | SWT.WRAP);
button.setText("V\ne\nr\nt\ni\nc\na\nl");
But unfortunately the lines will be centered as a whole and not individually, so the result does not look particularly good.

A keyboard with a UITextField

I have a table listing some strings, and what I want is when I tap the add button on the navigation bar, a keyboard with a textField would jump up, so I can input a string in the textField, then when I tap the return key, the keyboard disappear as well as the textField, and the new string is added to the table.
I already make up a nib file with a toolBar containing a textField, and I just failed to go on.
How can I implement this idea? Use the inputAccessoryView? If so, that means the inputAccessoryView of the textField which belongs to the toolBar is gonna be the toolBar itself!
This seem kind of weird and I have not been able to make it work till now.
Or is there another way for this idea?
Thanks a lot!
I've solved the problems by using notification instead of inputAccessoryView.
There is a sample code in XCode called "KeyboardAccessory", and it gives a good example about using keyboard notifications!
Or custom a view with a tab, and set it as the textField's inputAccessoryView, that would also work!

Resources