Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / A problem with highlighting text

Author
Message
Yodaman Jer
User Banned
Posted: 26th Jun 2009 04:10
So yesterday I started an interesting project; a primitive, Windows XP look-alike 'OS'. I opened up DarkEDIT and wondered what the heck I was going to code, then I though about trying to use boxes to re-produce some of what Windows looks like. I remembered seeing somebody do this months ago, but can't remember what board it was on.

Anyway, here's a screenshot of it so far, and then I'll tell you about the slight problem I'm having...



The problem I'm having is highlighting any of the text in the drop-down menu. When the mouse is over a certain region, it inverts the text and adds a little arrow to show that a sub-meu will pop-up (not yet implemented). It will invert perfectly, but I have no idea how to set it back to normal. If I use the CLS command, it only clears the screen of everything else and shows the inverted text!

I had no problems with resetting the highlighted 'Go' button, but this is proving difficult. Here's my code...feel free to copy it and run it, it's not like it's anything special. It's really just a bunch of boxes that look like Windows, it doesn't actually act like it. The unfilled box function was written by TheComet and I threw it in this program. It will have a use later.



Does anybody know how I can get it so that I can reset the inverted text back to normal if the mouse is no longer hovering over that certain area? I fear it may be caused by using a subroutine for the Go Menu.

To exit the Go Menu, just right-click. Thanks to any and all who can help me out with this, and I apologize if the answer is really easy! I also just wanted an excuse to post this work of mine, too.


Click to go to our website!
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 26th Jun 2009 04:38
What exactly is your problem Yoda?

Your signature has been erased by a mod because it was too big.CHANGE IT OR DIE!!!!!
Yodaman Jer
User Banned
Posted: 26th Jun 2009 04:47
My problem is that when I open up the menu and highlight the 'Applications' option (there's no apps yet, and probably won't be...), the text will invert the colors (to show that it's highlighted), and yet when I move the mouse away it doesn't reset back to normal. Here's a pic to show what I mean:



I think it's caused by using a subroutine for the drop-down menu. I think I know a way to get around it, but it'll take a little while. I'll post back to tell you how it works out.


Click to go to our website!
Yodaman Jer
User Banned
Posted: 26th Jun 2009 05:07
Ah-ha!

Sometimes the answer is very, very simple. I simply had to re-draw the boxes that form the taskbar before using the CLS command.

I changed the menu subroutine from this:


To this:



That fixed it right there! Here's the whole code for anyone who's interested:




Click to go to our website!
Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 26th Jun 2009 05:35 Edited at: 26th Jun 2009 05:36
Generally we use an array to store the menu and use a variable to store the current menu item selected.

Using your older code:


Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 26th Jun 2009 05:42
You shouldn't really have a DO loop inside a gosub, that's just wrong by definition; a gosub is a branch which needs to return to the main program but the loop prevents this.

You seem to have solved your issue so I'll just add my two cents for what it's worth (2c? lol).
Event handling is very important for a project like this, for two reasons; you only want to be processing what you need to so your program is economic, you also want to be able to perform many different types of operations (clicking, dragging etc) so distinguishing between these actions is vital for a good control system.

There are a few actions that can be performed in this environment: single click, double click and drag. You could double those if you're using both buttons or even use different combinations of buttons to make things really complex lol.
OK, so the way any mouse action is performed is through clicking a button. So naturally we first check for single click operations (usually selection), then if the button is released we...

There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer
Yodaman Jer
User Banned
Posted: 26th Jun 2009 18:02
@Grog:

That's a really neat way to do all of that! Thanks for writing that up, I'm definitely going to keep it that way.

@OBese:

I really have no idea what I'm doing, I'm just experimenting to see if I can simulate Windows without too much trouble. I'm using a Do...Loop inside the Menu subroutine because I have no idea how else I can open up the menu. Perhaps I'll think of a better way later on.


Click to go to our website!
Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 26th Jun 2009 18:39
Np.

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 27th Jun 2009 00:38 Edited at: 27th Jun 2009 01:16
@Jer
Quote: " I'm using a Do...Loop inside the Menu subroutine because I have no idea how else I can open up the menu."

Since you are waiting for the mouseclick you should use a conditional loop (while or repeat).
I feel that is beside the point though because this loop is holding up the whole program, this means you can't have any global stuff going on; say you added a clock to your toolbar, it merrily ticks away until you click the GO button, to keep it going you'd have to rewrite the code or point to a subroutine, and you'd have to do that for everything you add to this program. I think you can actually just remove the DO, LOOP and SYNC and it would be fine.

I know you are just playing around with code but a little planning will take some of the frustration out of your fun.
You don't seem to have any kind of limiter switch for your mouseclick, I'll give you one for free!


TGC Forum - converting error messages into sarcasm since 2002.
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 27th Jun 2009 01:13
The mouse is trickier than keys because it can be greater than one, to combat this we assign mouseclick()=1 to the variable; this works like any other condition, if it is true it returns a 1 otherwise 0.
If we wanted to focus on the right mouse button we'd assign mouseclick()=2

TGC Forum - converting error messages into sarcasm since 2002.

Login to post a reply

Server time is: 2024-05-20 09:26:24
Your offset time is: 2024-05-20 09:26:24