UIButton state is '5' when touchDown - uibutton

I have a custom button where I set the background and text colour for normal state and reverse them on selected state. I am facing following issue.
When button is in normal state, on touchDown event button moves to 'highlighted' state (integer value 1) which is expected.
When button is in selected state, on touchDown event button moves to state 5 (I am logging the state). I cannot find what this value corresponds to. This changes the text colour to same as background colour and hence the text becomes invisible until the button is pressed.
Can anyone tell me what is this state '5'?

It's the bit mask state for UIControlStateSelected|UIControlStateHighlighted

Related

I added toggle buttons on the access form like (YES or NO). How to save a value in the table, pressing on the respective buttons

I added toggle buttons on the MS ACCESS 2016 Form like (YES or NO). How to save a value in the table, pressing on the respective buttons and one more action is required, when I press the button change the colour (YES - "GREEN", NO - "RED"). Please help me with this.
enter image description here
Create an option group with toggle buttons, not separate buttons. You can bind the option group to the field in database, it will show selected and saved option.
You can adjust pressed color for each of buttons separately, so select green color for background of Yes button and red for No
If you need 3 state options (both not pressed, pressed Yes, pressed No), create option group with 3 buttons, default is neutral and make neutral button invisible

Slow label and picturebox event firing which are child of Button

i have developed custom control which inherits Button control, actually i`m creating button with one picturebox and label on Button(picturebox and label are child controls). I created same method and wired child controls to behave as clicking on parent(Button), it works but its slow no mather what i do(tried with InvokeOnClick, me.performclick, Me.OnClick(New EventArgs()), tried with same method for all events), but clicking on label or picture box is slow, i need it to be fast as clicking directly on button cause in my application is very important to be able to click on button twice in second for example, if you click on label or picturebox twice at second it will fire just one time not 2.
What i have been thinking of is to make label and picturebox invisible for event is it possible or anyother idea ?
Thanks in forward
You are doing battle with ControlStyles.StandardDoubleClick. Which is turned on for the PictureBox and Label controls but turned off for Button.
So when you are clicking rapidly on either the picturebox or the label then they'll generate the DoubleClick event instead of the Click event. You'll interpret that as "slow" since you probably didn't write a handler for that event. Subscribing the event and calling Me.OnClick is a workaround.
Just don't do this. PictureBox and Label are point-and-click convenience controls but they are extraordinarily wasteful. It takes just two lines of code in the button's OnPaint() method override to get the exact same outcome, minus the overhead and the event problems. Use e.Graphics.DrawImage() to draw the pb's image and TextRenderer.DrawText() to draw the label's text.
Using MouseDown event ensures the event is triggered once per click, regardless of click/doubleclick.

Group UIButtons to limit "selected" state

I have a row of 5 buttons, of which only one button should be "selected" at once. I call
[button setSelected:YES]
triggered by the corresponding IBAction to set the state of a touched button to "selected".
Is it possible to create some sort of button group where only the latest touched button of the row shows as selected and all others switch back to their "default" state? (kind of like radio buttons)
Is it possible to create some sort of button group where only the
latest touched button of the row shows as selected and all others
switch back to their "default" state? (kind of like radio buttons)
So radiobuttons then? A nice implementation called MNMRadioGroup does exactly that.
However, iOS also includes the native UISegmentedControl object which only allows one section to be selected at a time.

ignore mouse event on label inside panel

I am making a custom menu. I am applying colors on panels on mouse enter and mouse leave.
I have labels on these panels, and the mouse enter and leave events work snappy, but as soon as I hover over the label (on/inside) the panel, the mouse leave event is fired. I know I can just do the same thing for the label mouse enter event, but I am doing some other visual stuff, and I need to have the label mouse events totally disregarded. Any ideas?
Thanks in advance.
I eventually just used the menu control, and styled it accordingly. Does the job better than I could with code...

CF - Button when pressed receives a focus (bold border)

As the question is asked ... how can i prevent that from happening?
I have ZOOM IN and ZOOM OUT button that receive focus after pressed.
The button in CF does not have focus property so im guessing im required to do another painful workaround...
Any ideas?
This is the way the system draws the buttons when clicked. If you don't want this you'll have to redraw the button (and it various states) yourself