These are some methods I'm using in my OpenScript2.0 programming language's IDE that are really bad hacks and I was wondering if there are better ways of doing them. Any advice would be great.
Notice: Method #2 has been fixed, found out about keyboard accelerators
Hack method #1
When the user right clicks on either the workspace area or in the code, I force a left depression and release, then set a timer for 50 ms later to show the menu at the new position.....this seems like a really bad hack, as some computers might take longer than 50 ms to calculate the left click and increasing that time would cause an annoying delay.
For visual people:
That's where i process the right click
// This is a bad hack...try and fix it
SetTimer(hWnd,0,50,0); // Showing the menu 50 ms later
and that's the timer call
// Bad method of doing this...but until I find a better method this will have to work
// What this is is when you right click it sets a timer to wait for a little bit,
// allowing the mouse position to update, and then it places the menu at that position
KillTimer(hWnd,wParam); // Kill the timer right away
The reason why I have to do this is because when you right click, say, in the workspace tree, and....damnit, lemme get a screeny cuz i can't explain it very well in text. Please note Figure 1 shown below.
In the top box is just the normal view of the workspace tree.
In the bottom box is when the user right clicks on somewhere else. Now, if I didn't have that left click thing in there, notice how "Workspace" still has the selection ants around it? If I didn't have that code in there, the menu would pop up, you'd think you were doing something to "movin.ost" but actually you're modifying the workspace one....this gets really annoying, thus the reason why i put the code in there.
It basically just emulates the user clicking the item first and then right clicking...but this just seems so hackish to me...
Hack method #2--FIXED
This method is also another hack that I put together just for it to work, but because it's a hack has some drawbacks.
Take in to account the following code:
This is inside my WinMain message loop....REALLY bad idea, heh. What that code does is it tests (asynchronously) whether the user pressed the f5 key, and also if they pressed the control key, so it can either compile or run and compile the project...
// Very bad method for having a ctrl-F5/F5 hotkey. Look in to getting real hotkeys
UPDATESTATUSBAR("Saving all files",0);
What would be a much better alternative is to set up hotkeys in my IDE, but I have no idea (and no experience) with creating and using hotkeys inside of win32 applications. Anyone have any info on this or perhaps bookmarked a good msdn directory about them?
Those are the 2 hacks I've found in my IDE so far as I'm going through the code (cleaning it up so it's a bit more memory efficient), I'll post more as they're found and if I can't figure 'em out.
Thanks in advance