Announcement: Remember: you are giving away your fantastic ideas for free, and somebody else might even make money from them (or appear to). That's just how the world works! If you're worried about it, maybe you shouldn't post your ideas here.


Caravel Forum : DROD Boards : Feature Requests : Scroll Text Cursor (Why's it always gotta blink?)
New Topic New Poll Post Reply
Poster Message
RoboBob3000
Level: Smitemaster
Avatar
Rank Points: 1982
Registered: 10-23-2003
IP: Logged
icon Scroll Text Cursor (+2)  
Couldn't decide whether or not to post this in bugs or feature requests. This forum won out.

When inputting the text for scrolls, the cursor blinks, right? Like a good cursor should. However, when you're moving the cursor around with the arrow keys or what-have-you, the cursor continues to blink. Other word processing programs leave the cursor visible when moving it around to make it so you can keep track of it.

So that's all I ask for. A simple cursor that remains visible when you're moving it around. Kinda weak for a feature request, huh?

____________________________
http://beepsandbloops.wordpress.com/
03-09-2006 at 04:05 AM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
jamie
Level: Smiter
Rank Points: 365
Registered: 04-15-2005
IP: Logged
icon Re: Scroll Text Cursor (+2)  
so it does! I never noticed that before.

And so obviously unimportant, I had to create a fix :-)

This works... It basically makes sure the cursor is at the start of a 'display cursor' cycle each time a key is pressed.. It means that if you type fast enough, the cursor also remains static, but from typing this in my browser now, it seems that that works the same way too.. I guess most things do, I've just never looked before.

Anyway, maybe Mike will want to commit it to CVS, though you'll have to find some really new major bug to force a 2.0.14 release :lol
--- TextBoxWidget.cpp.orig      Thu Mar  9 11:10:32 2006
+++ TextBoxWidget.cpp   Thu Mar  9 11:18:04 2006
@@ -117,6 +117,11 @@
        const bool bShift = (KeyboardEvent.keysym.mod & KMOD_SHIFT) != 0;
        const UINT wOldCursorPos = this->wCursorIndex;
 
+       // Keep the cursor constant whilst a key is being pressed - Jamie, 20060309
+       this->dwLastCursorDraw = SDL_GetTicks();
+       this->bDrawCursor = 1;
+       RequestPaint();
+



____________________________
#f3i2g# Disclaimer: I'm Welsh, left-handed, and stupid. #f3i2g#
03-09-2006 at 11:22 AM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5485
Registered: 02-04-2003
IP: Logged
icon Re: Scroll Text Cursor (0)  
jamie wrote:
And so obviously unimportant, I had to create a fix :-)
Thanks, Jamie! That's exactly what the doctor ordered. I'll include this in the next patch.
03-09-2006 at 07:14 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5485
Registered: 02-04-2003
IP: Logged
icon Re: Scroll Text Cursor (0)  
I'm making a fix to this code. I'll do
DrawCursorNow();
RequestPaint();
for faster response and remove the RequestPaint(); at the bottom of the method.

03-10-2006 at 03:00 AM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
jamie
Level: Smiter
Rank Points: 365
Registered: 04-15-2005
IP: Logged
icon Re: Scroll Text Cursor (0)  
No problem!

Actually, looking at the code, it appears that "DrawCursorNow()" basically just sets the conditions so that HandleAnimate always draws the cursor when it's next run... So, wouldn't the RequestPaint() following the DrawCursorNow() actually either be a bad thing (shut off the cursor) ?

I was going to suggest wrapping the redraw around a condition so it wouldn't redraw if it was already visible, such:
<       this->dwLastCursorDraw = SDL_GetTicks();
<       if (this->bDrawCursor == 0)
<         {
<           this->bDrawCursor = 1;
<           RequestPaint();
<         }


Sorry, not trying to be pedantic, or anal, or argumentative.. Just trying to work out what's going on!

Cheers,
Jamie


____________________________
#f3i2g# Disclaimer: I'm Welsh, left-handed, and stupid. #f3i2g#

[Last edited by jamie at 03-11-2006 02:46 AM : Rusty Spoons!]
03-11-2006 at 02:20 AM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5485
Registered: 02-04-2003
IP: Logged
icon Re: Scroll Text Cursor (+1)  
Sure. The problem here is with setting the time of the last cursor draw to now. This will take 500ms more (iirc) for it to be drawn at its possibly new location. So, if you tap the cursor left or right, then it takes half a second to show up there. Setting the last draw time to 0 will make it draw immediately.
03-11-2006 at 07:41 AM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
jamie
Level: Smiter
Rank Points: 365
Registered: 04-15-2005
IP: Logged
icon Re: Scroll Text Cursor (0)  
Right, I get you.. And your way is neater.

However, I think mine does achieve the same thing:

DrawCursorNow just appears to force the next HandleAnimate() event to

1) set this->dwLastCursorDraw to the time NOW,
2) set this->bDrawCursor to 1
3) RequestPaint()

Mine "manually" does the job that HandleAnimate does, whist ensuring HandleAnimate() when triggered doesn't do anything (mine too resets the counter by setting this->dwLastCursorDraw to the time NOW).. Which I agree is a bit of duplication of code, but I think the effect is the same... no ?

By the way, in your method, wouldn't your RequestPaint() be superfluous, as when handleanimate is called, it does the RequestPaint() itself ?

Again, just trying to understand what's going on :-)

Cheers!

____________________________
#f3i2g# Disclaimer: I'm Welsh, left-handed, and stupid. #f3i2g#
03-18-2006 at 12:11 AM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5485
Registered: 02-04-2003
IP: Logged
icon Re: Scroll Text Cursor (+2)  
jamie wrote:
Mine "manually" does the job that HandleAnimate does, whist ensuring HandleAnimate() when triggered doesn't do anything (mine too resets the counter by setting this->dwLastCursorDraw to the time NOW).. Which I agree is a bit of duplication of code, but I think the effect is the same... no?
No. Note that in CTextBoxWidget::HandleAnimate, the check for when to do the next cursor draw is
		if (dwNow - this->dwLastCursorDraw > 500)
which means that when you set this->dwLastCursorDraw to now, then you must wait 500 more ms before it will draw. That's why DrawCursorNow() does the opposite of what you propose, setting this->dwLastCursorDraw backwards instead of forwards. Why not just try each method out on your end and watch what happens?

The RequestPaint call might be superfluous now.

[Last edited by mrimer at 03-18-2006 02:35 PM]
03-18-2006 at 02:33 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
jamie
Level: Smiter
Rank Points: 365
Registered: 04-15-2005
IP: Logged
icon Re: Scroll Text Cursor (0)  
I'm setting it to now to force it to wait 500ms more before UN-drawing - therefore with the finger kept on a key, continually setting it to 500ms means it isn't activated at all... And at the same time, I myself am flipping the 'drawcursor now' bit manually and immediately, rather than relying to drawcursornow to do it..

So, I'm intending that we never wait for 'handleanimate' to run, we effectively set the time to now to cause it to NOT run, and therefore to never change the cursor which we have 'manually' set to draw immeidiately on key press.

As I said, I agree it's a bit of repeated code, and I'm certainly not questioning your improvement, but I'm struggling to see how the effect is different.. I'm actually new to C++ (though I'm fluent in C) and I'm still trying to grasp how some of the things work.

Incidently, if you know of any good online reference for c++ I'll be most grateful. The only things I've managed to find by searching are 'from the ground up' -- I basically just want something that shows the differences and additions from 'c'. As it is, I've been learning c++ just by 'reverse-engineering' the drod source :)


____________________________
#f3i2g# Disclaimer: I'm Welsh, left-handed, and stupid. #f3i2g#
03-18-2006 at 09:08 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
trick
Level: Legendary Smitemaster
Rank Points: 2580
Registered: 04-12-2003
IP: Logged
icon Re: Scroll Text Cursor (+2)  
Incidently, if you know of any good online reference for c++ I'll be most grateful. The only things I've managed to find by searching are 'from the ground up' -- I basically just want something that shows the differences and additions from 'c'. As it is, I've been learning c++ just by 'reverse-engineering' the drod source :)
Try these:

http://www.parashift.com/c++-faq-lite/
http://www.cppreference.com/

- Gerry
03-18-2006 at 09:31 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
jamie
Level: Smiter
Rank Points: 365
Registered: 04-15-2005
IP: Logged
icon Re: Scroll Text Cursor (0)  
Cheers! Loading them now...

____________________________
#f3i2g# Disclaimer: I'm Welsh, left-handed, and stupid. #f3i2g#
03-18-2006 at 11:18 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD Boards : Feature Requests : Scroll Text Cursor (Why's it always gotta blink?)
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.9
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.