I am developing a cad software using GDI+ (c++/Cli and framework 3.5). When user wants to move a line I want to use arrow keys. Presently I am using Number Keys 4,6,8 and 3 for left right, up and down and 7,9, 1 and 3 for diagonal. How to get diagonal using Arrow keys?
Assuming you have Num Lock on, you could still use the 7, 9, 1, and 3 keys as diagonal arrows.
The 7 is the home key
The 9 is the page up key
The 1 is the end key
The 3 is the page down key
You would have to intercept those 4 keystrokes, and perform the diagonal move line function.
Try handling both keyup and keydown events instead of keypress. Accumulate the directions on keydown, move on keyup.
Related
A very minor annoyance of mine as this is something I need to do regularly, therefore it could speed me up considerably over time. Say I have the following four lines:
File.join(root,
'setup',
'pre-suite',
'install.py'),
If my cursor was resting before 'File' I can use CMD+SHIFT+Right arrow to highlight part of the line or the full thing, I can even move this line down the list by using the down arrow instead of the right arrow. However, I want to select all four lines using the keyboard only, is this possible? If so how?
Here on Windows Shift + Up/Down expands selection to include the line above/below.
Since you are on Mac (based on Cmd in your shortcuts) ... just use Preferences | Keymap and look what shortcut you have got there for Editor Actions | Up/Down with Selection actions.
Another idea - use Edit | Extend Selection few times in a row (how many -- depends on context and caret position). Try it -- it does wonders; especially useful when invoked in the middle of such code block/statement.
I want to send an Alt combination to another window within a on-screen keyboard.
With combination I mean when you hold down Alt and enter a number or hexadecimal(registry key has to be set for hex) combination:
ALT down, Add press, 2 press, 5 press, 1 press, ALT up
I tried
SendKeys.SendWait("%{ADD}251") but it's Alt+Add 2 5 1
SendKeys.SendWait("%{ADD}%2%5%1") but it's Alt+Add Alt+2 Alt+5 Alt+1
SendKeys.SendWait("%({ADD}251)") but it's Alt and then the other keys pressed simultaneously
Ref to MSDN
Any suggestions for a solution with SendKeys or other classes?
[Edit]
Solution:
Example for CharCode (Element of enum Source): ʊ = &H28A
Dim CharCodeUnicodeStr As String = Hex(CInt([Enum].Parse(GetType(Source), CharStr))).ToString
SendKeys.SendWait("%{ADD}%" & ChrW(Convert.ToInt32(CharCodeUnicodeStr, 16)))
Put the keys within parentheses to indicate that ALT should be held down while pressing the others.
SendKeys.SendWait("%({ADD}251)")
Have you tried
SendKeys.SendWait("%{ADD}%" & ChrW(&H251))
This will convert your hexa code into a char. Then if you have control over the other application you can revert this char back to a number...
How can I make it a key press would move my mouse cursor?
Is that possible? I figured out how to register a key press and recognize if it's an arrow, but I'm not sure if it's possible to use that input to move a mouse
Thanks in advance!
The CGWarpMouseCursorPosition method should do what you want. Apple Docs
CGPoint target = CGPointMake(10, 50);
// where 10 is x and 50 is y
CGWarpMouseCursorPosition(target);
When the user presses one of the arrow keys, have this run in a loop until the key is no longer depressed.
I have a panel with about six controls on the panel. I wanted to remove the controls from the panel and finally did so with MyPanel.Clear(). But before that I tried the following code that runs from a button click:
For Each b As Control In MyItem.MyPanel.Controls
MyItem.MyPanel.Controls.Remove(b)
Next
I would click the button and watch it, as well as the MyItem.MyPanel.Controls.Count in debug. As it went through, the count would reduce: to 5 to 4 to 3, then it would exit. If I clicked the button again it would remove two more, then the last one on the third click, so they all fit the bill and were all removed without changing anything. Why did it take three clicks? I'm obviously missing something simple here, I think, but I don't know what it is, and I'd really like to understand it. If I had to remove specific controls, it looks like I would have had a problem.
I ran into this issue myself and its odd it even lets you do it as you're modifying the collection in the loop you are referring to.This should be a better method.
If you like to remove them based on type
For i = Panel1.Controls.Count - 1 To 0 Step -1
If TypeOf Panel1.Controls(i) Is Label Then
Panel1.Controls.Remove(Panel1.Controls(i))
End If
Next
Odd that VB.NET even lets you do this, but essentially what you are doing is editing the collection you are iterating through. To better understand, pretend you are using a regular for loop from 1 to 6, at the first iteration you are removing object 1, leaving you with 5 objects, making the old number 2 object the first. The next iteration you remove the 2nd thing, which used to be the third, and so on. Most languages this is a run-time error.
What is happening is that you are deleting the controls starting from the first position and moving to the last. If the list has 6 records and you start deleting them like you are, programatically you are saying:
remove(0)
remove(1)
...
remove(5)
While you are doing that, the list is getting smaller. Once you delete the first item it drops from 6 positions to 5, then 4, then 3, etc. So midway through your code it tries to remove item at location 3 (4th item), but since you already removed 3 items, the list's size only contains 3 items and that position does not exist.
To properly remove them all, you would have to start at the back of the list and move to the front.
Perhaps something like:
For i As Integer = (MyItem.MyPanel.Controls.Count- 1) To 0 Step -1
MyItem.mypanel.Controls(i).Dispose()
Next
I have an application which uses a key combination that is composed of more than one "normal" (non-meta) key, ex Command + Space + Right Arrow. I trap this using special methods which works fine, but I want to display this key equivalent in a menu item to inform the user of its availability, ex:
DoSomething Cmd_>
(Command Space Right Arrow)
NSMenuItem setKeyEquivalent only accepts a single character, ex #" " for space, but i need to display more than one normal key equivalent in this field.
How can this be done?
NSMenuItem is extremely inflexible. You'd have to set a custom view on the menu item and draw the title, highlighting, animation, etc. yourself. Probably not worth the effort.
It can't. The key equivalent for a menu item is a single keystroke or a keystroke with modifiers (Shift, Cmd, etc.) Chords (a series of independently pressed keys) are not supported by Cocoa.
What is it you're trying to accomplish? There may be another way to do it.