Is there a checkbox-like button in WinRT-XAML?
What I mean, is there a button with an IsPressed (or equiv) property that will remain pressed after the user taps it? Then "unselects" after the user taps it again?
ToggleSwitch is what you're looking for
Yes, its called "Toggle Button" or "Toggle Switch".
For more details refer MSDN : WinRT control List
Related
I want to close the keyboard when the user clicks a particular tab.
What's happening now is that when the keyboard is open and the user wants to switch to another tab, he must close/minimize the keyboard first.
The prop on a ScrollView keyboardShouldPersistTaps does what I want, but only for a ScrollView, not for a TabNavigator component.
You can use a function to hide the keyboard and call it from onClick of that tab.
This is the function you should declare in the same class in which onClick of that tab exists.
#SuppressWarnings("ConstantConditions")
public void hideKeyBoard(View view){
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),0);
}
And then from the onClick, just call this by using hideKeyBoard();.
This will hide the keyboard whenever that tab is tapped.
And You should provide some of your code if seeking help.
I'm trying to make some controls just for their view. For example I need a button which remains unpressed when it's pressed, like it seems on visual basic editor. How can I make this button?
Edit: Here is what I want
Before press:
After press:
Just a few possibilites
WinForms: yourButton.Enabled = false
WPF: yourButton.IsHitTextVisible = false
Make a image of a button and place it in your form
I try to implement a custom ContextMenu in a LongListSelector.
I'm not using the ContextMenu from Microsoft.Phone.Controls.Toolkit, it's basically the same as in the Rowi App:
(source: hiddenpineapple.com)
Approach 1
My list item toggles a VisualState on hold and an overlay is shown with controls in it.
The problem
I can't find a way to go back to the default state when the user clicks outside of the list item (as in the default ContextMenu).
Approach 2
I've implemented a custom template for the toolkit ContextMenu which looks exactly the same. I had to move its margin top to -itemHeight, as by default it is below the item.
The problem
The problem with this solution is, that it automatically closes itself when opening and I couldn't figure out how to avoid this.
Another problem was that it didn't work well with TiltEffect.IsTiltEnabled from the Toolkit (visual problems).
I need your help
Any suggestions on how to get this working?
Answer
Thanks to Cheese, now I know how to properly close the menu when the user clicks outside.
His suggestion was to get the coordinates of a Tap event on the current page, and check if it's inside the menu. When not, close the menu.
So I added a Tap listener to the page when the menu opens, and removed it when the menu closes. From the page listener I got the event coordinates and could check if it's inside the control which holds the menu (same size and position). I received the position of the control with Point leftUpperPoint = control.TransformToVisual(page).Transform(new Point(0, 0)) and the rightLowerPoint by adding the ActualWidth and ActualHeight.
But then I realized:
Why should I even calculate if the tap is inside the menu? I always want to close the menu when the user taps anywhere on the screen. If it's outside, yes. If it's on a menu button, yes.
Another modification I made was to listen for MouseLeftButtonDown instead of Tap as it also triggers when the user swipes.
So I removed this code and came up with the following:
private void ToggleMenu(object sender, System.Windows.Input.GestureEventArgs e)
{
PhoneApplicationFrame frame = ((PhoneApplicationFrame)Application.Current.RootVisual);
VisualState state = this.States.CurrentState;
if (state == null || state.Name == "DefaultState")
{
frame.MouseLeftButtonDown += MouseDownDelegate;
this.State = "MenuState";
}
else
{
frame.MouseLeftButtonDown -= MouseDownDelegate;
this.State = "DefaultState";
}
}
private void MouseDownDelegate(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
ToggleMenu(sender, null);
}
This works perfectly!
Thanks to Cheese for the hint.
Something like this by #denniscode http://dotnet.dzone.com/articles/rowi-show-tap-menu
Approach 1 problem
The best solution would be:
Get the menus coordinates, when user makes a tap - you check are tap coordinates on menu or not, if not - dissmiss - simple.
Approach 2 problem
I guess you had some button in a corner and when you tapped on it - nothing happened? And when you dissmissed the Tilt all worked. It seems that tilt works faster than a click, so, tilt changes the button coordinates, and device thiks you have missed/or dragged off
You can use what #ScottIsAFool suggested and maybe create another Dependency Property on your TapMenu control of type UIElement named CloseWhenTappedElement and automatically listen for Tap events inside your control once set. For example
<Grid x:Name="TapArea"/>
<TapMenu CloseWhenTappedElement="{Binding ElementName=TapArea"}/>
Helo Experts,
how to add an action event like button action to tooltip in cocoa,when i click on tooltip i want to perform some action.is it possible in cocoa?.if YES could anybody help how to do this.
I am showing tooltip using NSStatusItem
Thanks in advance.
//tooltip is your NSStatusItem
[tooltip setAction:#selector(tooltipClicked:)];
This calls method tooltipClicked when clicked:
- (void)tooltipClicked:(id)sender { ... }
I have a mainscreen with a few buttons in it and I'm trying to assiciate each button with a screen call. I can't get it to work though. I created the button with the layout painter but I don't see how to make it functional.
Any ideas? Thanks!
open the screen painter
double click on the button
enter a Function Code (the field is above "Context Menu Form")
now that your button has a function code it will fire this OK-Code and the dynpros "PROCESS AFTER INPUT" will be run. add a PAI module to the dynpro and in the module you could for example make the following coding:
case sy-ucomm. " the ok code
when 'your_buttons_function_code_here'.
call screen YOUR_SCREEN_NUMBER_HERE.
when others.
" DO NOTHING
endcase.
You must create a screen & perform CALL SCREEN inside that event. There's a concept called PAO & PBO. You may refer that too. Few links for your reference..
http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbab2935c111d1829f0000e829fbfe/content.htm
http://www.abapprogramming.net/2008/04/sap-abap-syntax-for-call-screen.html