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.

Author
Message
Mugen Wizardry
User Banned
Posted: 7th Dec 2010 18:21 Edited at: 7th Dec 2010 18:22
Hi all. I'm creating a level editor which I am selling, which will be posted in the complete projects section. However, first off, I'm having a bit of a problem with selecting an object. What I would like to do is have the object once selected be selected even if I click on my level editor window. But if I click anywhere on the screen that's NOT a window or object, THEN set it to 0. I have tried to create an example.

Code:


Use the arrow keys / WASD to turn / move

Thanks!

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 7th Dec 2010 19:04
Your Get_Selection function is completely useless, it's checking if a variable is 0, set the same variable to 0, if not, set it to 1.

Remove it, and it works like you want it to.

Mugen Wizardry
User Banned
Posted: 7th Dec 2010 20:13 Edited at: 7th Dec 2010 20:19
No it doesn't. When I click the window, it turns back to 0.

I only want that to happen when I click something in the screen other than a window or object

EDIT: Here is the new code



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Mugen Wizardry
User Banned
Posted: 7th Dec 2010 21:59
Anyone? :/

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 7th Dec 2010 22:08
Oh i see, I misunderstood.

Probably not the best way in the world, but it works.



James H
19
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 7th Dec 2010 22:16 Edited at: 7th Dec 2010 22:19
Works fine for me as you intended
OS is win7pro64bit and using upgrade 7.5 in window mode
I can only lose the object selection choice focus by double clicking the window to make it fullscreen. Using the maximise and minimise buttons doesnt change the object selection choice focus either

ignore me - I also misread the all important part - you may need to look at finding a way to determine window focus and add that in, just a stab in the dark guess but maybe look at BBB plugin by BrendyBoy
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 7th Dec 2010 22:22
Oh! I'm so stupid, sorry, misunderstood twice.

IanM's plugins have a has focus() command.

Mugen Wizardry
User Banned
Posted: 7th Dec 2010 22:27
i have my own plugin im beta testing. Thanks you guys! It works GREAT!

So would I do it like this?

Function Get_Selected(Obj)
oldselected = selected
if obj = 0 and X Get Focus Widget()=window
selectobject = oldselected
else
selectobject = obj
endif
EndFunction selectobject

Thanks!

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 7th Dec 2010 22:31
I think that would suffice Good luck.

Mugen Wizardry
User Banned
Posted: 7th Dec 2010 22:33
One more thing. How would I make it lose focus again ONLY when clicking on anything OTHER THAN the object or window? Like if I click the blue area, it says 0, BUT if I click the window or object, it says > 0?

Thanks!

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 7th Dec 2010 22:38
I don't think I can help you there, it sounds like it's something to do with your plugin not reporting the correct focus window.

James H
19
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 7th Dec 2010 22:42
"once selected be selected even if I click on my level editor window. But if I click anywhere on the screen that's NOT a window or object, THEN set it to 0"
is the level editor window a child to the current window you refer to or vice versa? ie both are run by seperate exe`s that may or may not be open at the same time. If not then I would hazard a guess that you will need to introduce code in all programs to maintain a flagstate that can be communicated from one exe to the other. You would just need to check the flag state when focus changes. If its all one program then you would have to test the results from the focus widget I think before you can write any psuedo
Mugen Wizardry
User Banned
Posted: 7th Dec 2010 22:53 Edited at: 7th Dec 2010 23:05
Here's what I have. basically, if u click the mouse, then picked = Get_Selected(obj). Now I need to know how to turn picked to 0 if an object is currently NOT being picked and the background is being clicked instead

if mouseclick()=1 and X Get Focus Widget()<>window

picked = Get_Selected(Pick Object(Mousex(),Mousey(),1,find free object(1,0xFFFFFFFF)))

else

picked = 0

endif

Function Get_Selected(Obj)
oldselected = picked
if obj = 0
selectobject = oldselected
else
selectobject = obj
endif
EndFunction selectobject

Thanks!

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
James H
19
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 7th Dec 2010 23:26
If you have two programs running here you need one program to tell the other if focus has not been passed to the other directly.
When the window from program A loses focus it needs to check with program B if it has focus immediatly after program A lost focus. If focus was not lost to another application or Windows(desktop or other part of Windows) then pick should keep its current value but if it did then its value should change to 0.
Is this the situation?
If so I think you will need to use a high res timer in both programs that syncronise using a variable to make comparisons as both programs will not have been initiated at the same time(the nearest to them being initiated at the same time is one straight after the other).
Lets say the high res timers smallest unit/value is x. When focus from A is switched to B immediatly then the comparison variable would be an increment of x from program A to program B and vice versa. This would mean that pick value would remain the same. If the comparison variable was greater in difference than x then pick would equal 0.
Mugen Wizardry
User Banned
Posted: 7th Dec 2010 23:28
I've actually decided against the clicking the background thing, as it would be useless actually, because there will be MANY objects being loaded into someone's level, so the code you gave me is just fine! Thanks!

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!

Login to post a reply

Server time is: 2026-07-21 19:19:06
Your offset time is: 2026-07-21 19:19:06