473,614 Members | 2,487 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: Trap keyup event in canvas

>I have a canvas which I use for dragging shapes around such as rectangles
>and polylines. I can use the mouse down event on these objects to give
them a selected appearance, but I can't trap the keyup event. I need to
trap the keyup event so if the user used the delete key, I can remove the
object from the canvas (as a user would expect to do). I attached a simple
project which as a canvas and a few shapes in it. can someone please
advise on how I can trap a keyup event on these shapes?
Add
Focusable="True "
to the XAML for the PolyLine and Rectangle elements and then when you set
the focus to them they will receive the KeyUp events.

Chris Jobson
Jun 27 '08 #1
1 1556
Thanks Chris, this worked nicely.
"Chris Jobson" <ch**********@b tinternet.comwr ote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
I have a canvas which I use for dragging shapes around such as rectangles
and polylines. I can use the mouse down event on these objects to give
them a selected appearance, but I can't trap the keyup event. I need to
trap the keyup event so if the user used the delete key, I can remove the
object from the canvas (as a user would expect to do). I attached a
simple project which as a canvas and a few shapes in it. can someone
please advise on how I can trap a keyup event on these shapes?

Add
Focusable="True "
to the XAML for the PolyLine and Rectangle elements and then when you set
the focus to them they will receive the KeyUp events.

Chris Jobson

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
13414
by: Fred Sawtelle | last post by:
I'm trying to trap the Enter key in any of the key events (keypress, keydown, keyup) of the Windows .Net combobox control. Try as I might, I cannot get the event to respond to an Enter key press; nor can I find anything documenting this situation. Help is appreciated. Here's my code. This pops up a messagebox for normal alphanumeric keys, but does nothing at all when Enter is pressed.
1
4487
by: Ori | last post by:
Hi Guys, Here is my problem, but maybe someone can help me with this. Background: 1. Using C#. 2. I'm having a form which the KeyPreview is on (and must stay like this) and I'm implementing some functions on the Key up event of some controls and the form.
2
2348
by: Adam J. Schaff | last post by:
I have recently noticed an unwanted behavior that I do not know how to get rid of. To Recreate Problem: Windows Forms App with 2 forms. Form 1 has nothing on it and this code underneath: Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp If e.KeyCode = Keys.Return Then
4
7125
by: ShaneO | last post by:
I would like to handle the KeyUp & KeyDown events in the same event handler but can't find how to determine which event was fired - Private Sub ListBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) _ Handles ListBox1.KeyUp, ListBox1.KeyDown If e.KeyValue = Keys.PageDown Or e.KeyValue = Keys.PageUp Or e.KeyValue = Keys.End Or e.KeyValue = Keys.Home Then
2
1716
by: Rich | last post by:
Hello, I need to trap/detect when a textbox is entered via the tabkey. If the textbox is not empty when entered via the tabkey then set focus to next textbox. To enter that textbox would then require a mouseclick if it already contains text to be edited. I am guessing that I would need to trap for this in the Enter Event of this particular textbox. I tried this in the Enter Event of the Textbox, but...
0
2484
by: WaterWalk | last post by:
Hello. When I tried to make Tkinter canvas widget respond to MouseWheel event on Windows XP, I failed. The canvas just doesn't receive MouseWheel event. I used bind_all to find out which widget receives this event and the result showed that only the top Tk widget gets it. This is really annoying. I wonder if this problem exists on other platform. I googled, but found no appliable solution, so I wrote one as following. It's not perfect,...
8
13386
by: =?Utf-8?B?RyBIdXN0aXM=?= | last post by:
This is the 2nd time posting so sorry for duplications. I am using VB.NT 2005 & a standard Combobox. I've been wracking my brain over this problem for a over a month & cannot seem to find a way to trap the pressing of a Tab Key when the focus is in a Combobox. The KeyDown or KeyUp event for a combobox will not fire when the tab key is pressed. The Keyup event will fire when the Tab key is used to tab into the combo, however I want to trap...
11
5653
by: Ben | last post by:
Hello, I'm trying to catch the pressing of the left and right arrow keys through the KeyUp event, like so: public Form1() { InitializeComponent(); Form1.ActiveForm.KeyUp += new KeyEventHandler(ActiveForm_KeyUp);
2
6512
by: Linda Liu[MSFT] | last post by:
Hi George, Keyboard input introduces the idea of focus. In Windows, a particular element is designated as having the focus, meaning that it acts as the target for keyboard input. The user sets the focus by clicking the mouse or tapping the stylus on the control in question, or by using navigation keys such as the Tab and cursor keys. In principle, any user interface element can receive the focus. The IsFocused property is defined on...
0
8198
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8642
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7115
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6093
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5549
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4138
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2575
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1438
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.