Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7742165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:12:49+00:00 2026-06-01T09:12:49+00:00

I want to do a map editor for a game. Its a program that

  • 0

I want to do a map editor for a game. Its a program that will have Windows Forms UI (like propertyGrid to edit object’s properties) but it will also have a panel on which map will be drawn.

What i want:

When focus is on the panel with the map, i’d like to use keyboard to move map around (arrow keys), add objects (number keys) etc. When focus isnt on this panel, i’d like the buttons to work as normal in windows forms – allow to tab between controls etc.

My form looks like this:

It has a ToolStripControl that has a menuStrip (for main menu) and a statusStrip (for status bar). In the middle of the form (or toolstripcontrol), SplitControl is docked (dock=fill) that has two panels. Panel 1 has the PanelMap – a Panel that displays the map, Panel 2 has all other stuff like propertygrid, tabcontrols, buttons etc.

I have KeyPreview of form set to true and process keyboard events in form’s keydown event handler.

Now, what happens is if i assign focus to PanelMap, next time i press an arrow key, NO KeyDown event fires. Not a single one! Even form which is supposed to process all events because it has “KeyPreview” doesnt get its even to fire. When i press an arrow, PanelMap loses focus towards the SplitControl.

Okay, i thought, maybe PanelMap is not supposed to ever have focus, lets give focus to SplitControl (if i press arrow key while it has focus, i can handle it so it doesnt go further). But then, if anything like a textbox that is inside something that is inside SplitControl has focus, then SplitControl CANNOT get focus. .Focus() will do nothing – focus remains in the whichever control that had it!

Why does it act so strange? Why doesnt Form’s KeyDown fire when panel has focus and arrow key is pressed? Why doesnt SplitControl get focused when i call .Focus() even though CanFocus=true?

And ultimately, how do i achieve what i want? Is there a way to do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:12:51+00:00Added an answer on June 1, 2026 at 9:12 am

    I think you’re running into the widgets taking the keystrokes before your events get to them for navigation. I had this issue, and did this:

        private void RemoveCursorNavigation(Control.ControlCollection controls)
        {
            foreach(Control ctrl in controls)
            {
                ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(MainWin_PreviewKeyDown);
                RemoveCursorNavigation(ctrl.Controls);
            }
        }
    

    I call this function in the main form’s Load handler, like this:

    RemoveCursorNavigation(this.Controls);
    

    In your PreviewKeyDown handler, you need to do this:

        public void MainWin_PreviewKeyDown(Object sender, PreviewKeyDownEventArgs e)
        {
            switch(e.KeyCode)
            {
                case Keys.Up:
                case Keys.Down:
                case Keys.Left:
                case Keys.Right:
                    e.IsInputKey = true;
                    break;
                default:
                    break;
            }
        }
    

    The e.IsInputKey = true; tells the outside that you’ve used this event, and don’t want it going anywhere else.

    Now you get to see the keystrokes before they go to the widgets, and you won’t get navigation between them from the cursor keys.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this object graph, I want to map: abstract Account (username, password, ...)
I have a high-resolution image that I want to use as a tiled map
I want to map a INI file as a python object. So if the
I have a situation where I want to map a pair of objects to
I have a javascript object, and I want to recursively search it to find
I want map a List of beans to a JTable. The idea is that
I want to map a route like this: mysite.com/username in ASP.NET MVC 3 application;
I'm working on a vector map editor and I have a set of elements,
Suppose that I want to customize the indentation rules of the foton document editor,
i am going to start a chess like board game. and for that i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.