How can i change the selection of textfield copy paste options - swift

1)Take Input from Text Field and Input will show on bottom of Text field and Input has multiple Words.
2)Long press on single world It will appear a toast with multiple option opy ,paste ,change color .
3)Click on change color option selected Word should be change color .
4)Click on double click It should be redirect with same words.

Add addition menu item using UIMenuController, something like this:
let changeColor = UIMenuItem(title: "Change Color", action: #selector(changeColor:))
UIMenuController.shared.menuItems = [changeColor]
You can make the changes in changeColor function and update textfield's content from there with your color attributes.
Double-tap is used to show menu controller options, changing that may not be straight forward change. You need to explore swizzling to achieve that.

Related

How to set first responder for NSTextView in Swift?

Edit: in a macOS project
I have a simple ViewController which I display as popover on a status item menu app.
I change the text of the view text with a NSTableView, depending of which item is clicked. The code I use is similar to this one:
mainTextField.insertText(newStr, replacementRange: theRange)
(I use insertText for the purpose to have the change recorded in undo manager)
Then I highlight the text:
// create the new NSRange
let range = NSRange(location: startRange, length: newStrLength)
// select the range in field
mainTextField.selectedRange = range
All work fine, except that the text is highlighted but with a light grey instead of the usual sky blue, indicating that the control is not the first responder. And when I click on the field the selection disappear.
Actually I would like that the NSTextView becomes first responder so I can directly copy the selected text.
Edit: if I press Tab key on the keyboard I got the textView to become first responder (and the grey selection becomes standard sky blue).
Corrected Answer
In AppKit, you need:
if mainTextField.acceptsFirstResponder {
mainTextField.window?.makeFirstResponder(mainTextField)
}
In this case, it's probably safe to not check acceptsFirstResponder, but it doesn't hurt either.
Original Answer (UIKit)
You need to call mainTextField.becomeFirstResponder().

How to Change the cursor in JavaFX Accordion title bar

I'm using custom cursors and it need to be differ in some components in my screen.
When I set the cursor for Accordion, it doesn't effects title headers but effects the body of each TitledPanes. I even tried to set the cursor for each TitledPane but it doesn't effect the title header. I'm using following way to change the cursor.
ImageCursor cursor_title = new ImageCursor(cursorImg_title,cursorImg_title.getWidth() / 2,cursorImg_title.getHeight() / 2);
accordionBody.setCursor(cursor_title);
Is there a way to change the cursor in title bar of a JavaFX Accordian?
More....
I have changed the padding of title bars using css as follows. Hope it doesn't have any relation to the problem.
.titled-pane > .title {
-fx-padding: 30;
}
A TitledPane is divided into two parts :
Title
Content
When you are setting the Cursor on the Accordion, it delegates it to the content of each TitledPane, but leaves the Title. This is by design.
To force your application to change the cursor on the title as well, we need to set it on each of these nodes. We can fetch all the nodes by using the lookupAll() on the accordion and passing the styleclass they use i.e. .title. Make sure you use this after the scene graph is visible.
accordion.lookupAll(".title").forEach(node -> node.setCursor(Cursor.CLOSED_HAND));
You can use your custom cursor in place of CLOSED_HAND.

ListGrid / ListGridField - Hover message while editing

Is there a way to show a hover message on an editable cell/ListGridField while in Edit mode?
Was able to have a hover message over a cell in non-edit mode by :
cusipField.setShowHover(true);
cusipField.setHoverCustomizer(getCusipHoverCustomizer());
Thank you
You should be able to manipulate the properties of the editor that is created when you enter edit mode for a field through an appropriate FormItem and the ListGridField.setEditorProperties(FormItem editorProperties) method. For example, if your field is storing texts, you shall create a TextItem and define the hover text using its setPrompt(java.lang.String prompt) method. Then use that TextItem to set the editor properties for the field.

In GWT need to set the value of list box to the one,that was was selected in other selection

I have a full search panel with listbox whose value are read from DB.when a item in listbox selected and search is made.If the results are not found the search panel is condensed (one more search panel) and in condensed search ,we can change the search criteria ,selected a different item in the list box .after changing the search criteria and if search is made ,when the full search panel appears,the value of the list box in full search panel should be same as the one changed/selected in the condensed search panel.
How can we accomplish this.
In simple - If i have two list boxes, load a list box and set the value of the listbox same the other listbox.If value of one listbox is changed, the other should be changed and the value of this listbox is set with the value selected in the previous one.
I would do the following
//you have something like this
ListBox listbox1;
ListBox listbox2;
//add a change handler
listbox1.addChangeHandler(new ChangeHandler() {
#Override
public void onChange(ChangeEvent event)
{
int index = listbox1.getSelectedIndex();
//do your update code here for listbox2
//like a listbox2.setSelectedIndex(index) or something
}
As far as I see its an easy implementation. Add a value change handler on the first listbox and do whatever you want in onChange method.
Regarding your panel need to be collapsed when there is no search results, you can always use vertical panel and set its height to 100% and add another panel to it or Use Dock Panel and add panels to south or best use disclosure panel and play around with it.

Checkboxes in Xcode

What I'm wanting to do is add checkboxes and have a title for each checkbox and have if certain boxes are checked then it displays certain texts like
if box 1, box 2, box 4, and box 5 are selected then displays text1
if box 1 is selected then displays text2
if box 1, box 3, and box 4 are selected then displays text3
Something like that. Help would be appreciated. Thanks.
For the UI use a UiTableViewController with two images one for unchecked and the other for the checked state. Those images are assigned to the UITableViewCell's imageView property.
For checking state, I would store all values into one int field and make a corresponding typedef enum so that i could use a bitwise & to check to see if a value or combination of values is selected.
I could post some code later if needed.
You can use UISwitch controls for a simple on/off control, and UILabel controls for text. You could have a single UILabel whose text changes, or multiple ones and mark them hidden depending on which switches are on.