Well, I have a Button on my Window.
The following describes what I would like to do:
Touching the Button with the Mouse (I assume, the best event would be MouseMove), should open a new DropDown at the Button. (Something similiar like a Combobox DropDown)
This Dropdown will be filled with data, and each item is an event (item will show the name of the event as string in the DropDown), which calls a method that I'm at the other hand determining over Reflection.
What I actually would like to know, is, if it is even possible, to accomplish this task?
Creating a new DropDown at or beside the button, when the user touches the Button with the Mouse?
How would you do that?
You could create a Context Menu and display it on the buttons Mouse Enter Event.
See MSDN ContextMenu for more information.
The Extended Wpf Toolkit got something like that:
DropDownButton
For touch I think the closest event is mouse enter and mouse leave. And could you not just have a ComboBox or ListBox and manipulate the visibility (on the mouse enter and mouse leave events). For mouse leave would need to be on panel with both the button and DropDown.
Related
I'm wondering how you can get a dropdown menu to blend in with the button clicked as seen in the above image. I've created a flat button with no border to mimic the look of the Edit, View, Project, etc. buttons, and have added a ContextMenuStrip to act as a dropdown whenever one of the buttons is clicked. The image below is however the best I could make it.
Is it perhaps some tool other than a Button + ContextMenuStrip that needs to be used to achieve a blending look like the first image? Thank you for any help.
You can use a MenuStrip control:
I just want to add simple thing, wherever i click on TextBox I want to delete text that is inside. The thing is I DON'T have in list of events, event called Click.. Is this even possible? Or just I need to install some add on. Buttons are fine, they have Click event.
MouseButtonLeftUp would work if you only are concerned with mouse clicks. With that said, what if someone tabs into the box or focus is entered by other means?
At that point you may want to look at the GotFocus event. Any time the TextBox receives focus, you can handle the event.
TextBox has events called MouseLeftButtonUp and MouseLeftButtonDown, you can use them.
i've been searching on internet for the property that says that a normal button was selected or not, i think there must be one because when you click a button, it turns light blue, regardless the mouse is over it or not, and when you click another button, the previous button changes back to normal and the new clicked button is set light blue.
I need it to know which button was just selected and draw a "resizing" square on it, and it gotta last as long as the button remains as the "selected one".
thanks in advance.
What you are looking for is the Focused property. For actually any Control it returns, whether it has input focus or not (so e.g. hitting Enter will cause the button to be clicked as well). Since it sounds like you want to be notified whenever that property changes, you should use the GotFocus and LostFocus events.
You can give a Control focus programmatically by calling Focus.
you can do two things,
you can do it with the events: mouseEnter and MouseLeave,
this events launches when the mouse enters or leaves the visible control area,
also the focused(boolean) property gets and sets the "selected" element
one solution could be to:
private void onElementMousenter(blablabla,sender e);
{
e.Focused=true;
}
and assign the mouseEnter events in all controls to this one so the last element will be the "selected one" until you select another
I have an "On screen keypad" with some up/down/left/right/select buttons.
The select button is effectively a click and the arrow keys fire the associated up/down/left/right key.
The problem is that when selecting a combo box, I can't press the down/up buttons to navigate the items in the list. It is because the combo box auto closes when loosing focus. I can see similar problems happening with other controls, so I would like to see if there is a way to do the following.
For certain buttons (up/down/etc), when clicked, fire the click event, but don't take focus from w/e currently has the focus. This would allow the combox dropdown to stay open while pressing up/down to navigate through the items.
I have tried to set Focusable=False on the navigation buttons but the focus is still taken away from the combo box and the dropdown closes.
Any ideas/suggestions?
Thanks in advance
This isn't happening because of anything your Buttons are doing so changing their focus state won't make any difference. ComboBoxes close when you click anywhere outside of them, including empty space, non-interactive controls, other windows...
I am trying to replicate an intellisense like feature where you have a textbox and a menu that's shown below it. I know intellisense doesn't use ContextMenuStrip, but my version has to have categories which are sub-menu items.
So as soon as the user clicks into my TextBox, I bring up the menu below once, but then even though I can see the caret in my TextBox it doesn't receive any key inputs. I have to click inside the TextBox again but that removes the menu from the screen.
Is there a way to prevent this? Or perhaps make the menu persistent on the screen without stealing focus?
ToolStrip control with items added to it seems to work since it's always on the form.