I have created a GUIDE script with 5 push buttons. Each button creates a different graph for given data. I would like every time I push one of the buttons (let's call it Button1), the button to look like it is pushed or maybe change color or title (I would prefer it to look pushed). When a different button(let's call it Button2) is pushed I want Button2 to look pushed and Button1 to look like it was initially.
Also when I plot figures and I use a title on top of the figure, GUIDE cuts the top part of the title. Is there any way to have the title on the inside of the figure or maybe closer to the top axis so that all of it is visible?
(HARD) In the ButtonDownFcn callback for each button, put code that sets the BackgroundColor property. (You can see all of the available properties for any control by choosing View/PropertyInspector in the main menu for GUIDE.) Since you only have 5 buttons, the easiest way to get what you want is to just copy and paste code between them, with appropriate changes.
Pseudocode for Button 1:
Button1.BackgroundColor=PushedColor
Button2.BackgroundColor=NonpushedColor
etc for rest of buttons
(EASY) Use a group of radio buttons instead. They do what you want, automatically.
To reposition the title, you just change the Position property of the title's text box.
Related
i'm trying to manage different state of a simple push button on an OS X application : When the user click on it, and when the user release the click.
Currently i set my button type by NSMomentaryLightButton
NSMomentaryLightButton When the button is clicked (on state), it
appears illuminated. If the button has borders, it may also appear
recessed. When the button is released, it returns to its normal (off)
state.
This type of button is best for simply triggering actions because it
doesn’t show its state; it always displays its normal image or title.
This option is called Momentary Light in Interface Builder’s Button
inspector
I thought it was the good way, but when i print my button status, it's like a toggle button than the push button that i set. As you can see on exemple gif
To sum up, How can i have a real push button behaviour ? Call function when the user click on it, and when the user release the click.
Thank,
You don't want to use buttons for piano keys. First, they are non-rectangular, and they don't act as buttons do: neither single-action push-button, nor toggle switches. You are interacting in a custom way, with a custom view, meaning the NSButton control hierarchy isn't called for. Instead you're subclassing NSView and capturing low-level mouse events as detailed here:
https://developer.apple.com/library/prerelease/content/documentation/Cocoa/Conceptual/EventOverview/HandlingMouseEvents/HandlingMouseEvents.html#//apple_ref/doc/uid/10000060i-CH6-SW1
You found this yourself as you detailed in your own comments, but I wanted to make sure you had a higher level point of view. It's even possible, and probably best, to consolidate all of the piano keys into a single view, and let the keys themselves be rendered using NSBezierPath and perform mouse hit detection using containsPoint:
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSBezierPath_Class/#//apple_ref/occ/instm/NSBezierPath/containsPoint:
This is a lot more work but the only way to make a truly professional looking piano simulation. Then you can render the keys with whatever outline, fill, and labeling you need without the limitations of built-in button shapes and layout. You could even have the bottom edges of the keys slightly rounded, for example, or apply a shiny texture.
I see many posts explaining how to display a label after clicking on a button but it seems nobody has raised the question of how to actually display the label text directly ON the button itself.
I am coding for the AppleWatch and due to the small screen size, it would seem that saving space and actually having the label display on the button instead of above or below or to one of the sides to be something of a perfect solution.
Specifically, what I am trying to do is create a tap counter with the incrementing number be on the button itself. Tap the number (or button) and it increments by one.
Possible?
You can create a label with transparent background, and place it on top of a button.
However, this is not an ideal solution: rather than displaying a label on top of a button, you could change the text of the button itself. This way you would have the same visual effect with fewer objects on the screen:
button.setTitle("Text you wanted on the label", forState: .Normal)
I have a main form...imagine that...that for most of my users will be the only form they use. Naturally, it contains tabs with sub forms.
I have a navigation sub form on the left side of this form that changes based on the user's rights level. Currently, this sub form is all buttons...and 1 always is selected as the default tab stop for that form.
I don't want to highlight any of them at first...and I can remove the highlight by switching off Tab Stops for all buttons. However, I'm not sure that I want to remove that functionality all together...and it still highlights a button. I'd just like for there to not be a default button highlighted.
As you can see, Add Course is 'selected'. I can't seem to find the correct terminology to search for a way to do this. I tried using a smaller button set behind another button, but since it has the focus, it moves to the front. Using a text field with the same colors as the background shows the cursor in a random, blank area...not visually ideal.
I'm sure that there is someone here clever enough to have this figured out. Please enlighten me. I don't care if this can be handled in VBA code or through design view.
"Focus" is the word you're looking for - you don't want any visible control to have the focus when opening the form.
The easiest method is an invisible button: create a button with Transparent = True, and an empty OnClick (i.e. the button does nothing, even when accidentally clicked).
Move this button to the top in the Tab Order, so it has the focus when opening the form.
But if your users use TAB to walk through the buttons, there will be one position where the focus disappears (when circling around from the last to first control). I don't know if it will confuse them.
Create a button on the main form itself.
Named is cmdDummyButton with the following GotFocus event code.
Set the tab order property to 0 (ie first)
Make the button transparent.
This will cause no control on the form to have the focus when it starts up.
Private Sub cmdDummyButton_GotFocus()
Static IveHadFocusAlready As Boolean
If Not IveHadFocusAlready Then
Me.cmdDummyButton.Enabled = False
IveHadFocusAlready = True
End If
End Sub
Sweet.
I want to add a new toggle button to the figure toolbar. When it is clicked, I want to "untoggle" any other buttons that were toggled. E.g, if the "rotation" or "zoom" toggle buttons were pressed, I want to untoggle them and their effect.
Simply getting all their handles does not work, as this does not deactivate their effect.
You should first find all of the children of toolbar. You can do it by the following command (Assuming that currentToggleButton is a handle to current toggle button):
get( get(currentToggleButton,'Parent'),'Children');
Then do the following:
set(children,'State','off');
Of course, you need to return the state of your current button to on.
set(currentToggleButton,'State','on');
By the way, if you are using GUIDE, you can add zoom,rotate and pan as pre-defined tools. In that case, Matlab will handle the toggling automatically.
In order to turn off the effect of zooming/pan/rotation, you can do:
zoom('off')
pan('off')
rotate3d('off')
or you can use another syntax version (as #Eitan also mentions)
zoom off
pan off
rotate3d off
Ok so could anyone please help me out with the VB for auto entering information into a text box, by clicking certian label boxes on a form in access 2003.
I built this thing using label boxes as "sort of links" instead of button for navigation/commands etc, and I have this power point presentation viewer on one of the forms.
The client has numerous briefings and this will be great for me to provide a little something for them to be able to get their briefings from one spot.
So if I list the choices for the month out on the form as label boxes (with little mouse move events to resemble a web link) and they click on it to select, then the only way I know how this may become functional is if I add a text box to the form, and make it not visible, that way I can name it, and add it to the file path string and it works.
But how do I create the action of clicking the "link" result in "NVOWEFDJHF" into text box?
Anyone know a better way?
Yeah I am an amateur, so I am ALWAYS willing to learn a better way.
Thanks very much!
I would recommend using a transparent button instead of a label.
The main reason is that you can set the mouse cursor to become a small hand when you hover over the button, so it gives back information to the user that this can be clicked.
With a label, the user cannot make the difference between a normal label and one that can be clicked since there is no visual cue.
To create a button that resemble a label:
Add the button to the form
In the properties for the button, set the following:
Format > Back-Style: Transparent
Other > Cursor on Hover: Hyperlink Hand
Other > Name: btAutoFill (or whatever name you want)
If you want the button to resemble a link a bit more, you can change it's caption's format, making it blue and underlined if you wish.
Now if you view the form, you will see that the mouse cursor will change when you move over the 'button label'.
To automatically fill-in other controls when you click your button, add the code to handle its OnClick event (in the button's properties, under Events > On Click, choose [Event Procedure]):
Public Sub btAutoFill_Click()
myTextBox = "NVOWEFDJHF"
End Sub
Quick air code here...
Private Sub MyLabel_OnClick()
Me.MyTextBox = "NVOWEGDJHF"
End Sub
Don't forget your error handling.
You're making this as difficult as possible by using an approach that is not Access-native. The simplest way to make the labels "clickable" is to put a transparent command button over them. But that means the MouseMove events will go to the command button, so you'll have to have its events do the MouseOver actions.