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 / New Menu Functions

Author
Message
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 6th Nov 2009 00:37
I was working on these for my WinGUI project but then i realized they would work standalone with minimal changes(just 2 lines actually) so i figured i post em up here. if no one uses them, maybe they can help someone create there own menus someday.


It supports up to 101(counting array 0 lol) menus, up to 100 items(per menu), spacers, sub-menus, and icons for the items. the example explains everything

New Site! Check it out \/
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 6th Nov 2009 02:52
@Caleb1994
This is real nice! It might be just what I was looking for an editor I'm making. One thing maybe you can take a look at is, if you right click too close to the right edge or bottom of the screen, the submenu or even the main menu doesn't display correctly. Perhaps you can make the menu draw in the opposite direction, rather, the opposite side of the mouse. Or measure to the edge or bottom of the screen and adjust the drawing accordingly.

Good work!

Enjoy your day.
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 6th Nov 2009 03:46
Thanks latch!

I completely forgot about the menu placement! thanks! I will fix that right now!

New Site! Check it out \/
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 6th Nov 2009 05:46
Oh, one other thing. Can you move the menu text so that even if it doesn't have an icon, it is lined up in the same space that a menu item with an icon would be?

Enjoy your day.
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 6th Nov 2009 07:13 Edited at: 6th Nov 2009 07:38
Sure! The 'customer' is always correct

Actually that takes away one if lol.

edit:

is this up to your specifications???? hahaha nah it's cool i always love suggestions =P



New Site! Check it out \/
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 6th Nov 2009 09:29
Quote: "is this up to your specifications???? hahaha nah it's cool i always love suggestions =P"

Actually, if you are willing, the menu still has trouble displaying when it's close to the bottom of the screen.

And, is there anyway you can make this a series of sub-routines instead of functions? The reason I ask is, it would be great to drop this inside another function. Say, for example, there is a function to open a file dialog box, if your code could be dropped into that function as a series of sub routines and local arrays, then that dialog box function can have it's own menu that's activated by right clicking and only when the function is called.

The reason I'm asking is to make the arrays local (to another function) and not have to call outside functions (from the funciton the code is embedded in. Entire apps can be written this way as plugins to existing source without having to deal with or modify global arrays or functions. You just drop the function with all of it's local variables and procedures into the source and call it from the main source whenever you need it.

Enjoy your day.
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 6th Nov 2009 18:48 Edited at: 6th Nov 2009 18:51
I am always willing!

What exactly do you mean by 'having trouble' is it not shifting above the mouse or is it doing something completely weird? lol


I will see what i can do about the subroutines. are you saying you want it also where the ShowMenu doesn't have a loop and doesn't pause the rest of your program? that would need a UpdateMenu function/subroutine also to be called every loop. in the mean time i will put them in subroutines for you.

Edit:

I just thought of something. If you want the AppendMenu and stuff to be in a subroutine, then how would you pass parameters? like item ID and stuff. do you want a separate variable or array to hold those values then just call the subroutine and it would use them?

New Site! Check it out \/
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 6th Nov 2009 23:48
Quote: "What exactly do you mean by 'having trouble' is it not shifting above the mouse "

When the mouse is too close to the bottom, it does not display the menu when you right click at all.

Quote: "are you saying you want it also where the ShowMenu doesn't have a loop and doesn't pause the rest of your program?"

It's ok if it's modal and pauses the program until you choose an item or left click somewhere.

Quote: "I just thought of something. If you want the AppendMenu and stuff to be in a subroutine, then how would you pass parameters? like item ID and stuff. do you want a separate variable or array to hold those values then just call the subroutine and it would use them?"

Instead of local parameters, variable values can be assigned directly:



One of the things to work out would be the internal function calls would have to be replaced with subroutines also.

Don't go to any trouble with this. I could fiddle around with the functions to get subroutines the way I want them. Your menu is fine as it's own function library. I just want to have a dedicated series of subroutines that I can stick inside of functions (you can put subroutines in functions, but you can't put functions in functions otherwise I would just do that). That way, instead of having multiple libraries and tons of globals to declare, I can have it contained in a single function as if the function is a complete app in and of itself.

Enjoy your day.
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 7th Nov 2009 01:44 Edited at: 7th Nov 2009 01:46
Found the problem. A misspelled variable(that's one downside to not having to declare them :/) I can't upload the latest version now, but will soon.

Quote: "
Don't go to any trouble with this.
"


Nah it's cool! If it makes it easier for you then at some point down the road someone else will probably have the same idea! as long as a i have time and a(large enough ) brain i will work on the specifications that people suggest! That being said if I suddenly don't have time then it might stick in function form lol.

So would something like this work for like the AppendMenu part,



I will try and get a working model up like this by sunday. no guarantees though! lol

New Site! Check it out \/
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 13th Nov 2009 19:02
If you haven't messed with this, don't bother. I can manage the subroutine system.

Enjoy your day.
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 15th Nov 2009 22:20
Ok, sorry. as i said the other post. got busy(really busy) and forgot about this.

New Site! Check it out \/

Login to post a reply

Server time is: 2024-03-28 20:37:25
Your offset time is: 2024-03-28 20:37:25