Change ListBox selected item on finger tap, not on finger release - windows-phone-7

The Windows Phone ListBox control changes the selected item when the user releases the finger after having tapped the item. I would like the selected item to change as soon as the user taps the item, without waiting the finger to be released. Is there any way to achieve this?
Actually what I want to do is to handle the ListBox "Hold" event to do something on the selected item. Currently, two taps are needed (one short tap for selecting the item, and another one for the hold behavior), and I would like one tap to be enough bor both changing the selected item, and the hold behavior.

Use the Hold gesture instead.
If you need a context menu, use the ContextMenu from the [Silverlight Toolkit].

Related

change ListView item image at runtime (firemonkey)

I need the ability for a user to press and set an ListView item's checkbox independently of clicking on the item. If they press on the checkbox I will add/remove the checkmark and take some action. If they press on the item text I can take another action.
I can do this with a ListBox no problem with built in functionality. I can't figure out how to do it with a ListView. How is it done?
I can put the following code in the ListView1ItemClickEx to know when the user is clicking on the image. Maybe I can just change the image to a checkmark?
if (ItemObject->Name == "I") {
ShowMessage("Item Image clicked");
}
But I don't know how to change that particular items image (e.g. I could just toggle between a checkmark image and an unchecked image) at runtime.
The picture below is for clarity. Clicking anywhere in the red box will change the items checkbox. For the ListBox clicking anywhere in the blue box will fire the OnClick event and not change the checkbox. I want that same behavior in the ListView.
Ok, Remy answered this related question and it helped me solve this issue. Now I can make the ListView have a checkbox that functions like that of the ListBox. I do it by toggling the item image whenever the user presses (or clicks on) the image area of an item.
When the user clicks an items image I trap it (per Remy's code in the ListView1ItemClickEx event) and toggle it from 0->1 or 1->0 in a vector at reference ItemIndex (e.g. myVector[ItemIndex] = 0) and then I completely rebuild the ListView (clear it and build from scratch).
I thought I'd have to remember where in the list I had scrolled down to and after refreshing the ListView I'd have to scroll to that point in code - but, that isn't the case. I don't know why but after the refresh I'm still at the point in the list where I clicked an item image. It makes it work and feel exactly like a check box.
It works great in iOS, Android, and Windows.
p.s. I forgot to mention that you need to treat any Header's like they are items in your vector that keeps up with each items' image (0 or 1). Otherwise adding headers gets you out of sync and clicking an item's image will toggle some other item's image.

NSMenuItem with NSVIew and Key/Mouse Events

I'm using a NSView within a NSMenuItem to allow me to change the padding and menu item height.
Unfortunately the view eats up the scroll wheel and key down/up events as describe in the documentation. However, there doesn't seem to be a way to pass these events back to the menu so it works like before where Key up/down would change the highlight selection, and the mouse wheel would scroll the list if it is too long. Has anyone come across a solution?
Edit:
This is not the same as the duplicate. I can already get the mouse up/down events for the custom view. My problem is that I have no way to pass these events back to the menu to do what it used to do.
For example how do I get the menu to scroll when the menu gets to long in response to a mouse scroll event?
How do I select and highlight the next item on the list in response to a Key Down event. Passing the event to the menu (or any of its superview/window) doesn't do anything, and there are no functions to do something similar that I can see/

Is it possible to remove and move a row of listbox on itself?

Just like the UITableView on iphone.
users can remove or move a row on UITableView.
There is only one button to switch the UITableView to editing mode.
but for listbox on wp7 , I need 3 buttons, one for removing the selected row, one for moving the row up, one for moving the row down.
Welcome any comment
The Windows Phone ListBox doesn't support these features out of the box, but it would be possible to add them yourself using a DataTemplate.
Here's a blog post about creating a custom DataTemplate for your ListItems.
At a high level, you'll need to create a template that contains:
Enter edit mode button
Delete button
Sort up/down buttons
Then in your code, you'll need to toggle the visibility of the delete and sort buttons, as well as handle user clicks on each of the buttons. Doable, but a fair amount of work.
In my opinion, a better option would be to use a approach that's different from what you might be used to but is more familiar to Windows Phone users: the ContextMenu. This control allows you to pop up a menu when the user performs a long touch (tap-and-hold) on an item.
Here's a good tutorial about incorporating this control into your app.
Take a look at re-order ListBox here. It shows how to retemplate the ListBox.
For removing on item, you just need to remove its data source item. See how to use ObservableCollection.
If you want to show effect when an item is removed, use Event Triggers for the Unloaded event.

First item in an NSMenu does not appear

I am making my own NSMenu programmatically and popping it up when a button is pressed.
I create NSMenuItems and add them with the NSMenu method insertItem:atIndex:.
For some reason whatever item is at position zero in the menu does not show up. Is this how the menu is supposed to work?
Yes, this is how the menu is supposed to work, if the NSPopUpButton pullsDown. The first item corresponds to the title of the button; just insert "" or whatever you want. It won't show up.
So you're building your menu in reverse order (by iteratively calling insertItem:anItem atIndex:0)? Why not just build it from the top down and successively call addItem:? I've done this lots and never had issues with items disappearing.

Scrollable menu using MenuItem's

What I am trying to accomplish with Cocos2d, is to create a horizontal menu, which can be swiped from left to right. I posted an image, to show my idea.
The image below has a white bar, where I want to show MenuItem objects, now I want to be able to do a swipe in the white region, so that the next menu item is centered.
Example http://www.wimhaanstra.com/images/MenuExample.png
The problem I am facing is, I would really like to use the Menu (& MenuItem) functionality of Cocos2d, but it seems somehow that the MenuItem object does not accept touches other than just tapping it. Also I want the swipe to be detected not only on the MenuItem, but the whole white bar.
What would be the best approach for this?
Somehow incorporate an UIScrollView, but that would be a shame, because I would like to use OpenGL for everything
Subclasss the MenuItem class, to create one where the ccTouchBegan is handled, and somehow move the whole Menu?
Just leave the whole Menu idea behind, and replace the Menu and MenuItems with sprites which support touching.
I read somewhere that MenuItem's shouldn't really be used for this kind of work, but why not?
Layer can handle touches event.
you can put you menuItems into one layer.
detect a swipe, and move the the menuItems

Resources