I have a button in UI Builder of type NSButtonTypeMomentaryChange.
The button is transparent, with an alternate image which displays when the button is clicked, or trackpad is pressed over the button.
But when using a soft "Tap" on the trackpad, while the buttonpressed: event is triggered, the momentary change alternate image is not displayed.
How can I configure ViewController to display and perform the momentary change action for taps on trackpad?
Related
I have a UISegmentedControl element where there are two buttons (i.e "Delete all Points" and "Delete Pt #x"). I don't want the buttons to ever remain selected so I have them set as "momentary = YES". I also don't want to handle click events until AFTER the user has released a button. The problem is, I can't figure out which of the two buttons was pressed within the UISegmentedControl view.
What I've tried:
1) I've tried using the "ValueChanged" event. The nice thing here is I can get the selected index for which button was pressed (even when momentary=YES), but the problem is that this event if triggered when the user presses down... which I don't want. I want the event when the user releases their finger, and at that I only want the event when the user releases WITHIN the button view
2) I've tried using the "Touch Up Inside" event. But it doesn't trigger any events when I tap on one of the buttons...
Any help on this would be appreciated. (Programming in Objective-C)
I'm not sure what you mean when you say "I've tried using the "Touch Up Inside" event." Unless you specify precisely what you tried, with code, that is just a meaningless phrase.
Ideally, you'd want create a method something like the following, and set it up as the button's action:
- (IBAction)myButtonTouched:(id)sender forEvent:(UIEvent *)event {
if (event.type == UIControlEventTouchUpInside) {
// do your thing
}
}
Basically you send every user event for that button to the handler and test for the one you want.
I have a problem with the button, it's weird but it disappears.
I click on it and it brings me to an other view and then i click back and i am back in my Mainview but without button.
I've added this button in storyboard - not progamatically.
Time to start debugging: Start by putting a breakpoint on viewDidAppear: and in the console type:
po self.whateverYourButtonIsCalled
Check frame, isHidden, the superview's subviews, transforms, etc.
Currently I have an IBAction for a NSButton, and the NSButton also has a key equivalent. I would like to know if there is a way inside my IBAction function "strike"
- (IBAction)strike:(id)sender
that can tell me whether this action is triggered by a mouse click on the button or a press of the key equivalent of the button?
get the current event using -currentEvent and using if loop check for mouse click count
if([theEvent clickCount]>=1)
{
mouse clicked;
}
else
{
button pressed;
}
I have a set of UIButtons and a UISegmentedControl with 3 segments inside my storyboard.
The segments of UISegmentedControl should work as following;
When first is selected, show all buttons,
When second is selected, hide Button - Button1 and Button - Button2,
(When third is selected, hide Button - Button1, Button - Button2 and Button - Button3).
What should I do to achieve this?
Assign the view controller to be your segmented control's target and implement the action message. You can either do this in IB or using addTarget:action:forControlEvents: and setting the event type to UIControlEventValueChanged.
In the value change action method hide or show the buttons you want using their hidden property.
I have a NSPanel in my MainMenu.xib called filePanel, it has a NSView called filePanelView. When buttons are clicked, I will load a NSView from a nib and add it to the filePanel like this:
[NSApp activateIgnoringOtherApps:YES];
[filePanel setIsVisible:YES];
[filePanelView addSubview:[fileBrowseViewController browseView]];
The problem is that the controls on these subviews can never be brought into focus. For example, a NSTextfield that is set to be editable is not editable, and doesn't have a focus ring around it when clicked. I can click buttons though. But on another window, a determinate progress bar has it's progress measured in grey instead of blue. Is there something I'm doing wrong in terms of needing to manually set these views as having focus?