wxTextCtrl Doesn't Display a Cursor Topic is solved
- ColleenKobe
- Earned some good credits
- Posts: 109
- Joined: Mon Aug 31, 2015 3:47 pm
wxTextCtrl Doesn't Display a Cursor
I have written a short program to give me practice navigating among text fields and buttons on the screen. Everything works fine, as far as moving from field to field, and typing, changing, and saving values goes.
The one thing that puzzles me is that there is no cursor displayed in the wxTextCtrl field that is the focus. I can type and the characters are displayed, but if I didn't change the focus text control background to yellow, it would be impossible to know where the cursor is on the screen without typing something.
I'm sure I've missed something obvious, like a bit needs to be set somewhere.
How can I get a cursor to display in the wxTextCtrl fields?
CodeLite: 10.0.0
wxCrafter: 2.6
wxWidgets: 3.1.0
Thanks!
The one thing that puzzles me is that there is no cursor displayed in the wxTextCtrl field that is the focus. I can type and the characters are displayed, but if I didn't change the focus text control background to yellow, it would be impossible to know where the cursor is on the screen without typing something.
I'm sure I've missed something obvious, like a bit needs to be set somewhere.
How can I get a cursor to display in the wxTextCtrl fields?
CodeLite: 10.0.0
wxCrafter: 2.6
wxWidgets: 3.1.0
Thanks!
Re: wxTextCtrl Doesn't Display a Cursor
Hi,
Can you compile the text sample and see if it works for all controls out there?
Thank you.
Can you compile the text sample and see if it works for all controls out there?
Thank you.
- ColleenKobe
- Earned some good credits
- Posts: 109
- Joined: Mon Aug 31, 2015 3:47 pm
Re: wxTextCtrl Doesn't Display a Cursor
Thank you for replying, ONEEYEMAN.
You're talking about the sample code that came with wxWidgets, right? On my computer, they text samples are installed in C:\wxWidgets\samples\text.
Actually, no, I have no idea how to compile those samples. I tried to compile them when I first downloaded wxWidgets, but I got confused. There were lots of mystery (to me) abbreviations, and the directions required me to know which ones I needed, and I didn't. I wasn't sure what I was supposed to be doing, or how to tell when I did it correctly. I didn't know where to get help. Finally, I just "walked away." Now I work in CodeLite, wxWidgets, and wxCrafter.
You're talking about the sample code that came with wxWidgets, right? On my computer, they text samples are installed in C:\wxWidgets\samples\text.
Actually, no, I have no idea how to compile those samples. I tried to compile them when I first downloaded wxWidgets, but I got confused. There were lots of mystery (to me) abbreviations, and the directions required me to know which ones I needed, and I didn't. I wasn't sure what I was supposed to be doing, or how to tell when I did it correctly. I didn't know where to get help. Finally, I just "walked away." Now I work in CodeLite, wxWidgets, and wxCrafter.
Re: wxTextCtrl Doesn't Display a Cursor
Yes, that's the one.ColleenKobe wrote: Thank you for replying, ONEEYEMAN.
You're talking about the sample code that came with wxWidgets, right? On my computer, they text samples are installed in C:\wxWidgets\samples\text.
Well, then. I think now is a good time to "un-confuse" you.ColleenKobe wrote: Actually, no, I have no idea how to compile those samples. I tried to compile them when I first downloaded wxWidgets, but I got confused. There were lots of mystery (to me) abbreviations, and the directions required me to know which ones I needed, and I didn't. I wasn't sure what I was supposed to be doing, or how to tell when I did it correctly. I didn't know where to get help. Finally, I just "walked away." Now I work in CodeLite, wxWidgets, and wxCrafter.
Let's try to solve the mystery of compiling wx samples.
What compiler did you use to compile the library? How did you compile it - inside IDE or from the Terminal/Command Prompt?
Thank you.
- ColleenKobe
- Earned some good credits
- Posts: 109
- Joined: Mon Aug 31, 2015 3:47 pm
Re: wxTextCtrl Doesn't Display a Cursor
Oh, hey! Awesome!!!ColleenKobe wrote: Actually, no, I have no idea how to compile those samples. I tried to compile them when I first downloaded wxWidgets, but I got confused. There were lots of mystery (to me) abbreviations, and the directions required me to know which ones I needed, and I didn't. I wasn't sure what I was supposed to be doing, or how to tell when I did it correctly. I didn't know where to get help. Finally, I just "walked away." Now I work in CodeLite, wxWidgets, and wxCrafter.
ONEEYEMAN wrote:Well, then. I think now is a good time to "un-confuse" you.
Okay!ONEEYEMAN wrote: Let's try to solve the mystery of compiling wx samples.
I compiled the library originally using a Windows 7 command prompt. I'm not actually sure I did it right, because every time I compile a program now, I get dozens of "deprecated" warnings like this one:ONEEYEMAN wrote: What compiler did you use to compile the library? How did you compile it - inside IDE or from the Terminal/Command Prompt?
Code: Select all
F:/Prototypes_CPP/Navigate_Fields/Baseline/MainFrame.cpp:433:1: warning: 'virtual void wxWindowBase::SetInitialBestSize(const wxSize&)' is deprecated: use SetInitialSize() instead. [-Wdeprecated-declarations]
Re: wxTextCtrl Doesn't Display a Cursor
Ok, I presume you used MinGW compiler of some flavor, right?ColleenKobe wrote: I compiled the library originally using a Windows 7 command prompt. I'm not actually sure I did it right, because every time I compile a program now, I get dozens of "deprecated" warnings like this one:
All those warnings make it hard to debug a longer program.Code: Select all
F:/Prototypes_CPP/Navigate_Fields/Baseline/MainFrame.cpp:433:1: warning: 'virtual void wxWindowBase::SetInitialBestSize(const wxSize&)' is deprecated: use SetInitialSize() instead. [-Wdeprecated-declarations]
Which command{s} did you use to compile the library?
Thank you.
- ColleenKobe
- Earned some good credits
- Posts: 109
- Joined: Mon Aug 31, 2015 3:47 pm
Re: wxTextCtrl Doesn't Display a Cursor
Yes, I used MinGW.ONEEYEMAN wrote:Ok, I presume you used MinGW compiler of some flavor, right?
Which command{s} did you use to compile the library?
Here is the batch file I created to compile wxWidgets. I know it's wordy and long and a lot of it is commented out. But I thought that I'd have to help my co-workers do the same process, and I was worried I would forget steps. I
Code: Select all
echo off
cls
rem ----------------------------------------------------------------------------
rem Compile wxWidgets
rem ----------------------------------------------------------------------------
rem
rem Edited by Colleen Kobe
rem March 22, 2016
rem
rem Description: This batch file gives you directions to follow to download
rem and compile wxWidgets, gcc, and Code::Blocks.
rem
rem These directions work on the following software versions:
rem
rem gcc: 4.9.3
rem wxWidgets: 3.0.2
rem Code::Blocks: 16.01
rem
rem Note: I gathered the steps below from a number of
rem different web pages. No page listed all these steps.
rem That leads me to believe that there are a lot of different
rem errors that can happen during these installations. Many
rem of the "authorized" lists of instructions don't have these
rem errors. Why? Beats me.
rem
rem Directions. You must do the following tasks in order to compile
rem wxWidgets (and for this batch file to succeed).
rem
rem Most of this advice comes from
rem https://wiki.wxwidgets.org/Downloading_and_installing_wxWidgets and
rem https://wiki.wxwidgets.org/Compiling_wxWidgets_with_MinGW.
rem
rem 1. Download MinGW. See http://www.mingw.org/category/wiki/download.
rem See the additional documentation in F:\Documents\wxWidgets about
rem which options you'll need. I installed mine into C:\MinGW, so any
rem time I need to reference the MinGW directory, C:\MinGW's the
rem directory I'll use.
rem
rem 2. Download wxWidgets. See https://www.wxwidgets.org/downloads/.
rem Install it into a directory whose name constains NO BLANKS. I
rem installed mine into F:\wxWidgets F:\Documents\wxWidgets about which
rem options you'll need. I installed mine into F:\wxWidgets, and so any
rem time I need to reference the wxWidgets directory, F:\wxWidgets's the
rem directory I'll use.
rem
rem 3. Download Code::Blocks. See http://www.codeblocks.org/downloads/25.
rem
rem 4. Create an environment variable %WXWIN% and assign it the name of the
rem directory into which you installed wxWidgets. In my case, I'd assign
rem it the value F:\wxWidgets. See
rem https://kb.wisc.edu/cae/page.php?id=24500 for directions on creating
rem a system variable in Windows 7.
rem
rem 5. Append F:\wxWidgets and C:\MinGW\msys\1.0\bin to the system path.
rem See http://stackoverflow.com/questions/23400030/windows-7-add-path
rem for directions to change the path.
rem
rem 6. Still in the Control Panel: Make sure your system path does NOT
rem contain MSYS or CYGWIN directories. Delete those directories from
rem the path, if they're there.
rem
rem 7. Open %WXWIN%\build\msw\config.gcc. Find the string (without the
rem leading blanks):
rem
rem CXXFLAGS
rem
rem Change the line to read
rem
rem CXXFLAGS += "-std=gnu++11"
rem
rem Close config.gcc.
rem
rem 8. Open %WXWIN%\build\msw\makefile.gcc. Find the string (without the
rem leading blanks):
rem
rem ar rcu $@ $(MONOLIB_OBJECTS)
rem
rem There is only one line like it in the file. Replace that string with
rem
rem ~ar rcu $@ gcc_mswu\\monolib*.o
rem
rem EXCEPT replace the tilde (~) with a tab character (ASCII 0x09), and
rem the entire line should start in column 1.
rem
rem Close makefile.gcc.
rem
rem 9. You are now ready to run this batch file to compile wxWidgets.
rem First, be sure this batch file resides in %WXWIN%\build\msw. If it
rem doesn't, move it there.
rem
rem 10. Open a cmd.exe shell (click the Start button and type, in the
rem command box, cmd [Enter]. At the DOS command, type:
rem
rem cd F:\wxWidgets\build\msw
rem compilem
rem
rem Cross your fingers. Press the spacebar when prompted to. Hope like
rem crazy that it all passes.
rem
rem ----------------------------------------------------------------------------
echo on
set WXWIN=F:\wxWidgets
set origpath=%path%
F:
cd %WXWIN%\build\msw
rem ----------------------------------------------------------------------------
rem Clean up and build the debug version. Start by deleting the old files.
rem ----------------------------------------------------------------------------
erase /q F:\wxWidgets\build\msw\gcc_mswu\*.*
erase /q F:\wxWidgets\build\msw\gcc_mswuddll\*.*
erase /q F:\wxWidgets\build\msw\gcc_mswudll\*.*
rem ----------------------------------------------------------------------------
rem The "-j4" compiler option means use this many threads to compile. The
rem option works, but it makes debugging any error messages a little tricky. So
rem remove the option during debugging, but add it back in later.
rem ----------------------------------------------------------------------------
rem mingw32-make SHELL=CMD.exe -j4 -f makefile.gcc BUILD=debug UNICODE=1 SHARED=1 MONOLITHIC=1 clean
mingw32-make SHELL=CMD.exe -f makefile.gcc BUILD=debug UNICODE=1 SHARED=1 MONOLITHIC=1 clean
pause Debug File Clean complete. Ready to compile.
cls
rem mingw32-make SHELL=CMD.exe -j4 -f makefile.gcc BUILD=debug UNICODE=1 SHARED=1 MONOLITHIC=1
mingw32-make SHELL=CMD.exe -f makefile.gcc BUILD=debug UNICODE=1 SHARED=1 MONOLITHIC=1
rem ----------------------------------------------------------------------------
rem Clean up and build the release version. == wait to do this until the debug version works.
rem ----------------------------------------------------------------------------
rem mingw32-make SHELL=CMD.exe -j4 -f makefile.gcc BUILD=release UNICODE=1 SHARED=1 MONOLITHIC=1 clean
rem rem mingw32-make SHELL=CMD.exe -f makefile.gcc BUILD=release UNICODE=1 SHARED=1 MONOLITHIC=1 clean
rem pause
rem cls
rem mingw32-make SHELL=CMD.exe -j4 -f makefile.gcc BUILD=release UNICODE=1 SHARED=1 MONOLITHIC=1
rem mingw32-make SHELL=CMD.exe -f makefile.gcc BUILD=release UNICODE=1 SHARED=1 MONOLITHIC=1
rem ----------------------------------------------------------------------------
rem Have to do this copy manually--I don't know why.
rem ----------------------------------------------------------------------------
copy %WXWIN%\include\wx\msw\setup.h %WXWIN%\include\wx
Re: wxTextCtrl Doesn't Display a Cursor
#7 is not necessary, you should pass that parameter to the command line
#8 I've never seen that before, what's it supposed to do?
Very bad! Don't do this. Why do you think this is necessary?
I use VS almost exclusively, but when i experiment with MinGW, i use the following command line:
Regarding the samples: If you build the wxWidgets libraries successfully, you only have to navigate (still in the command window) to a sample, e.g. <wxdir>/samples/minimal/ and use the exact same command line that you used to build the libs.
Regarding the initial problem: Is this the same sample where you catch the wxEVT_KILL_FOCUS etc events? If yes, disable those and check if the problem disappears.
#8 I've never seen that before, what's it supposed to do?
Code: Select all
copy %WXWIN%\include\wx\msw\setup.h %WXWIN%\include\wx
I use VS almost exclusively, but when i experiment with MinGW, i use the following command line:
Code: Select all
mingw32-make -f makefile.gcc SHARED=0 MONOLITHIC=1 CXXFLAGS="-fno-keep-inline-dllexport -std=gnu++11" BUILD=debug
mingw32-make -f makefile.gcc SHARED=0 MONOLITHIC=1 CXXFLAGS="-fno-keep-inline-dllexport -std=gnu++11" BUILD=release
Regarding the initial problem: Is this the same sample where you catch the wxEVT_KILL_FOCUS etc events? If yes, disable those and check if the problem disappears.
Use the source, Luke!
- ColleenKobe
- Earned some good credits
- Posts: 109
- Joined: Mon Aug 31, 2015 3:47 pm
Re: wxTextCtrl Doesn't Display a Cursor
Okay.doublemax wrote:#7 is not necessary, you should pass that parameter to the command line
I don't know. I found a batch file for this online and I just copied it. This is what clueless people do.doublemax wrote:#8 I've never seen that before, what's it supposed to do?
Sigh. See above.doublemax wrote:Very bad! Don't do this. Why do you think this is necessary?Code: Select all
copy %WXWIN%\include\wx\msw\setup.h %WXWIN%\include\wx
Great! Thank you! I will try this to recompile my wxWidgets libraries.doublemax wrote: I use VS almost exclusively, but when i experiment with MinGW, i use the following command line:Regarding the samples: If you build the wxWidgets libraries successfully, you only have to navigate (still in the command window) to a sample, e.g. <wxdir>/samples/minimal/ and use the exact same command line that you used to build the libs.Code: Select all
mingw32-make -f makefile.gcc SHARED=0 MONOLITHIC=1 CXXFLAGS="-fno-keep-inline-dllexport -std=gnu++11" BUILD=debug mingw32-make -f makefile.gcc SHARED=0 MONOLITHIC=1 CXXFLAGS="-fno-keep-inline-dllexport -std=gnu++11" BUILD=release
if I remove the wxEVT_SET_FOCUS and wxEVT_KILL_FOCUS events, what should I do with the code in those procedures? Somehow, the user needs to be able to edit the text in those fields. Would wxEVT_ENTER_WINDOW and wxEVT_LEAVE_WINDOW do? Or do they refer to the window that the field resides in, not the field itself?doublemax wrote: Regarding the initial problem: Is this the same sample where you catch the wxEVT_KILL_FOCUS etc events? If yes, disable those and check if the problem disappears.
For what it's worth: here's what the display looks like now. The focus is in the cell for Channel 1, column "Diff Amp Minus Ref", which is the yellow cell. But this is with the "Set Focus" and "Kill Focus" events in place.
I would expect that there should be a dotted box around the text in the yellow cell, but there isn't.
I would expect the text in the cell to be highlighted when the field first becomes the focus, but it isn't.
And I would expect to see a cursor, but I don't.
P.S. I apologize for the long delay in replying here. I have to split my time at work between software development, laser welding, micro-grinding, and writing documents, and often, the other tasks take priority.
Re: wxTextCtrl Doesn't Display a Cursor
Hi,
Did you call "event.Skip()" in your EVT_SET_FOCUS()/KILL_FOCUS() handlers?
If not, you should do that. Without the call you prevent the OS to do its work on the control and hence you won't see a cursor.
Now, more generally, as a rule of thumb:
ALL NON-wxCommandEvent SHOULD CALL event.Skip()!!!!
Well, almost all of them. But it should be decided on case-by-case. And I believe it is even documented somewhere which events don't need to call it sometimes.
So for sure missing an event.Skip() call is the reason why you don't see the cursor there.
Thank you.
Did you call "event.Skip()" in your EVT_SET_FOCUS()/KILL_FOCUS() handlers?
If not, you should do that. Without the call you prevent the OS to do its work on the control and hence you won't see a cursor.
Now, more generally, as a rule of thumb:
ALL NON-wxCommandEvent SHOULD CALL event.Skip()!!!!
Well, almost all of them. But it should be decided on case-by-case. And I believe it is even documented somewhere which events don't need to call it sometimes.
So for sure missing an event.Skip() call is the reason why you don't see the cursor there.
Thank you.
Re: wxTextCtrl Doesn't Display a Cursor
That's only for a test to check if this is related to the problem. It wasn't meant as a permanent solution.if I remove the wxEVT_SET_FOCUS and wxEVT_KILL_FOCUS events, what should I do with the code in those procedures?
Can you comment out the code that sets the color for a test and check if the cursor appears?The focus is in the cell for Channel 1, column "Diff Amp Minus Ref", which is the yellow cell. But this is with the "Set Focus" and "Kill Focus" events in place.
Is there anything else non-standard you're doing?
Can you just add a default wxTextCtrl somewhere in the dialog and check if it shows a cursor?
If that all doesn't help, i'm afraid you'll have to try to create a minimal, compilable sample that shows the problem.
Use the source, Luke!
- ColleenKobe
- Earned some good credits
- Posts: 109
- Joined: Mon Aug 31, 2015 3:47 pm
Re: wxTextCtrl Doesn't Display a Cursor
You were right! I added theONEEYEMAN wrote:
So for sure missing an event.Skip() call is the reason why you don't see the cursor there.
Code: Select all
event.Skip (true);
Thank you. I can't imagine how I would have learned about event.Skip otherwise.
Colleen
- ColleenKobe
- Earned some good credits
- Posts: 109
- Joined: Mon Aug 31, 2015 3:47 pm
Re: wxTextCtrl Doesn't Display a Cursor
Oh. Sorry, I misunderstood.doublemax wrote:That's only for a test to check if this is related to the problem. It wasn't meant as a permanent solution.if I remove the wxEVT_SET_FOCUS and wxEVT_KILL_FOCUS events, what should I do with the code in those procedures?
I'd be happy to answer that question, if I knew what "standard" was. The problem turned out to be that I was missing an "event.Skip (true);" statement at the beginning of the Set_Focus and Kill_Focus procedures. Once I added them, the cursor and highlighting appeared normally.The focus is in the cell for Channel 1, column "Diff Amp Minus Ref", which is the yellow cell. But this is with the "Set Focus" and "Kill Focus" events in place. ... Is there anything else non-standard you're doing?
Thank you, doublemax, for your assistance!
Re: wxTextCtrl Doesn't Display a Cursor
Hi, Colleen,
The usual consensus is - perform what you need is the event handler and then call "event.Skip();".ColleenKobe wrote:You were right! I added theONEEYEMAN wrote:
So for sure missing an event.Skip() call is the reason why you don't see the cursor there.at the top of the local Set_Focus and Kill_Focus procedures, and now I have a cursor.Code: Select all
event.Skip (true);
Thank you. I can't imagine how I would have learned about event.Skip otherwise.
Colleen