I want to use the clear ✖️ button of an NSSearchField to close a search pane. Therefore I have manually set the action and target of the clear button cell. Now the button only appears when the search field has text in it and I can't find a way to override this behavior.
Is it possible to show the clear button at all times, wether there is text or not?
Related
I need the ability for a user to press and set an ListView item's checkbox independently of clicking on the item. If they press on the checkbox I will add/remove the checkmark and take some action. If they press on the item text I can take another action.
I can do this with a ListBox no problem with built in functionality. I can't figure out how to do it with a ListView. How is it done?
I can put the following code in the ListView1ItemClickEx to know when the user is clicking on the image. Maybe I can just change the image to a checkmark?
if (ItemObject->Name == "I") {
ShowMessage("Item Image clicked");
}
But I don't know how to change that particular items image (e.g. I could just toggle between a checkmark image and an unchecked image) at runtime.
The picture below is for clarity. Clicking anywhere in the red box will change the items checkbox. For the ListBox clicking anywhere in the blue box will fire the OnClick event and not change the checkbox. I want that same behavior in the ListView.
Ok, Remy answered this related question and it helped me solve this issue. Now I can make the ListView have a checkbox that functions like that of the ListBox. I do it by toggling the item image whenever the user presses (or clicks on) the image area of an item.
When the user clicks an items image I trap it (per Remy's code in the ListView1ItemClickEx event) and toggle it from 0->1 or 1->0 in a vector at reference ItemIndex (e.g. myVector[ItemIndex] = 0) and then I completely rebuild the ListView (clear it and build from scratch).
I thought I'd have to remember where in the list I had scrolled down to and after refreshing the ListView I'd have to scroll to that point in code - but, that isn't the case. I don't know why but after the refresh I'm still at the point in the list where I clicked an item image. It makes it work and feel exactly like a check box.
It works great in iOS, Android, and Windows.
p.s. I forgot to mention that you need to treat any Header's like they are items in your vector that keeps up with each items' image (0 or 1). Otherwise adding headers gets you out of sync and clicking an item's image will toggle some other item's image.
In my application I have a multi step form wizard in which
the next button is disabled unless all the required fields are entered.
Some fields require extra validation such as the directory picker,
for which I have to check whether the directory exists or not.
To ease the user experience I need to show an "Invalid directory" tooltip
next to the directory text field.
I would like to show the tooltips when the user tries to click/enter the disabled
next button.
Is it possible to capture events performed on a disabled button in JavaFX?
public void nextEntered(Event event) {
Button button = (Button)event.getSource();
if(button.isDisabled()){
validate(currentTab);
}
}
I had a similar problem where I wanted to show a tooltip of a disabled field's value when the user moused over that disabled field.
I ended up putting a blank label over the disabled field and attaching a mouse event to that.
In the case of a button, you can just give the dummy label mouse transparency when the button becomes enabled so the user can click the button.
(You might even be able to bind the label's mouse transparency property to the button's enabled property but I'm not sure.)
I know this was asked a year ago but maybe it will help someone else.
I have over 30 buttons and 30 images inside of a switch statement, 4 buttons showing at the same time. I want to perform an IBAction depending on which button is pressed. It's not allowing me to drag & drop it into the case inside my switch statement. The buttons change depending on what image is showing. For every image, there are 3 wrong buttons, and 1 correct button. How can I check for which button is pressed, and add a resulting action?
You are getting it totally wrong. You should use switch statement to control look and feel of UI. Like controlling the 4 buttons to be shown by simply using hide property.
Each button should have an IBAction defined at class level. So, drag and drop connection from XIB/Storyboard to class and not inside switch statement. Depending on which button is currently shown, it action would be triggered.
EDIT: Post OP clarification:
Since you are trying to set different image on same button based on some condition and want to handle the IBAction based on the kind of image you set on it, you would need to set the tag on the button in your switch statement where you are setting images. tag takes an integer value so you can create enum for readability. Then when button is tapped and your IBAction is triggered, put another switch statement to check the value of tag and then take action accordingly.
I have a bunch of buttons. They appears as an graphical image. If a user clicked on a button I can determine with
sender.titleLabel!.text!
which button the user pressed. But the title of the button appears in the view. I want only to show the image and give the button a invisible title. But I think that is not possible.
Me second solution is to create for each button an outlet. But I think with 30 buttons that is a very bad solution.
Option 1:
For the button text color property set opacity to 0. The text is there, but fully transparent.
Option 2:
You may use the tag value to identify a button so you do not have to rely on the button title. You can set the tag value in interface builder (Xcode) or in code. (The tag is an integer.)
I usually prefer option 2 as it is resilient to text changes over time (think of typos, translations for other languages etc.).
I have a page with a couple of widgets on it, each of which, when clicked, brings up a yui popup menu: If I click on widget 1, its menu comes up. If I now click on widget 2, widget 1's menu gets a hide event, and widget 2's menu gets a show event and comes up. I'd like to change this so that, when widget 1's menu is up, it must be explicitly dismissed by a click on the page background (and/or, perhaps, another click on the widget or the escape key) before the menu attached to widget 2 is allowed to appear.
I've set up some beforeShowEvent and beforeHideEvent handlers on the menus, hoping to be able to use some method (a global variable? ick) of keeping track of when a menu is present and showing or hiding accordingly, but it's not working -- these handlers can't tell the difference between a click on the page background and a click on widget 2 (at least, not as I've done it so far). Is there any way to do what I'm trying to do? Thanks!
I think that a combination of clicktohide: false
Boolean indicating if the Menu will automatically be hidden if the user clicks outside of it. This property is only applied when the "position" configuration property is set to dynamic and is automatically applied to all submenus.
and keepopen: true
Boolean indicating if the menu should remain open when clicked.
will take care of this.
http://developer.yahoo.com/yui/menu/#configref