Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I hide the cursor? 1

Status
Not open for further replies.

BioDJ

Programmer
Oct 5, 2001
10
0
0
NL
I'm working with Tcl-Tk while I call it from APL(2C). But this is purely about Tcl-Tk. The cursor can be set by :

. configure -cursor type

where . is the window name and type is the cursor type (e.g. wait or arrow). Now the file that contains all these cursor types (cursorfont.h) does not have a "hidden" cursor. So one solution could be to make the color of the cursor transparent. According to the manual that can be done with the following:

. configure -cursor type[foreground[background]]

but when i use any color it says: "green is an unvalid command name". So while i just want it to be an option, it interprets it as a command.

Who knows how to apply a color to the cursor, or a totally different way to hide the cursor? Any help or suggestion is appreciated.

Dirk-Jan van Leeuwen
 
Based on this and a previous post of yours, I'm suspecting that you're reading some type of documentation that describes a commands such as this with a syntax diagram such as:

[ignore]command [option [option]][/ignore]

If that's the case, the [ignore][option][/ignore] syntax indicates an optional argument, rather than indicating that you are supposed to actually include the [ignore][][/ignore] characters.

In other words, your script shouldn't have the line:

Code:
. configure -cursor watch [green [black]]

But you should instead have a line like:

Code:
. configure -cursor watch green black

The square brackets ([ignore][][/ignore]) serve a function similar to backquotes (``) in shell progamming; they execute the contents as a command, and then capture the return value for use in another command. - Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Thanks for the reaction. But it doesn't seem to work yet. The syntax in my documentation is actually:

-command option [fgcolor[bgcolor]]

When I try your suggestion it says "green is an unknown option" so it does interpret it as an option. Maybe the cursor-color isn't implemented in the version of Tcl-Tk I'm using...........anyone any other ideas?

BioDJ
 
The proper syntax for setting the cursor and attributes would be (example):
. configure -cursor {hand1 white black}

You can make the cursor invisible by setting the foreground and background colors to the color of the underlying window:

. configure -cursor "hand1 [. cget -bg] [.cget -bg]"

Hope this helps
Mike Suttles
Xerox OPB Technology Development Group
 
Thanks for your reaction. it doesn't work though. This is what it says, when I apply your suggestion:

unknown option "hand1 SystemButtonFace SystemButtonFace"

As you see I can get the background color with . cget. but it doesn't recognize "hand1". it also doesn't work when i change hand1 in any of the cursor types:

bad cursor spec "wait SystemButtonFace SystemButtonFace"

Just like when I place the quotes AFTER the hand/cursor type:

unknown option "SystemButtonFace SystemButtonFace"

Well, hard problem as it seems.....maybe someone has yet anotehr good idea?

BioDJ

 
Okay, just "thinking out loud" for a moment...

First of all, if you got the error message:

[tt]unknown option "hand1 SystemButtonFace SystemButtonFace"[/tt]

that leads me to believe that you might have forgotten the -cursor option when typing your command.

Secondly, if you got the error message:

[tt]bad cursor spec "wait SystemButtonFace SystemButtonFace"[/tt]

this suggests to me that you're running on Windows. And on Windows, you can't specify the foreground or background colors of a cursor. (Sorry.)

Thirdly, on page 546 of Brent Welch's Practical Programming in Tcl and Tk, 3rd ed., he says that on Windows you can turn off the cursor by using the cursor name [tt]no[/tt]. However, when I tried it on my system, it didn't work; instead, it displayed the circle-with-a-slash "disabled" style cursor. I don't know why that might be the case. And the online documentation doesn't mention the [tt]no[/tt] cursor at all, so there's no help there.

Fourthly, the online documentation says that on Windows you can specify the name of a cursor file (either [tt].cur[/tt] or [tt].ani[/tt]) to use with the syntax:

[tt]widgetName configure -cursor cursorPathname[/tt]

I was successful with this. On my system, I tried:

[tt]. configure -cursor @C:/WINNT/Cursors/coin.ani[/tt]

and it worked fine. So, if you could figure out how to create a Windows cursor file, you could create a blank cursor and use that.

Fifthly, why hide the cursor at all? I can think of very few instances where I as a user want my cursor to disappear on me. About the only one that comes to mind is when I'm displaying PowerPoint slides in full-screen mode. If you really, really want to hide the cursor and can't find a way to do it, my best suggestion is to pick a fairly inconspicuous cursor like [tt]crosshair[/tt] and go with that. - Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top