473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to determine if one control overlaps the other?

Jay
Hi all,

I know how to find a controls' position obviously (i.e.style left,
right, top, offset, etc.), but what I'm a little stumped on is, if
given two controls' positions, how can I tell if one is overlapping/
invading the space of the other?

For example, I have an AJAX dragpanel and am experiencing the common
'bleed through' of dropdown controls when I drag the panel over them.
Naturally the customer doesn't like this. I experimented a little with
the IFrame solution, but did not have much luck. It seems easier now
to just use the 'ondragend' event and show/hide dropdowns accordingly.

Does anyone have a piece of code where, given two control objects as
passing parameters, it returns true or false in regards to them
overlapping or not?

THANK YOU...

Oct 3 '07 #1
4 3148
Jay wrote:
I know how to find a controls' position obviously (i.e.style left,
right, top, offset, etc.), but what I'm a little stumped on is, if
given two controls' positions, how can I tell if one is overlapping/
invading the space of the other?
Compare the coordinates of the corners of one element against the
coordinates of the corresponding corners of the other one.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Oct 3 '07 #2
On Oct 4, 8:45 am, David Mark <dmark.cins...@gmail.comwrote:
On Oct 3, 2:26 pm, Jay <Jay.Pomp...@gmail.comwrote:
[...]
For example, I have an AJAX dragpanel and am experiencing the common
I don't see what AJAX has to do with this, but anyhow...
'bleed through' of dropdown controls when I drag the panel over them.

That's because you didn't hide the inputs when the drag operation
started.
Inputs? I think you mean select elements. Hiding them to stop them
"showing through" is pretty ugly from a users' perspective.

Naturally the customer doesn't like this. I experimented a little with
the IFrame solution, but did not have much luck. It seems easier now

That Iframe "solution" is not a solution (it is an ugly workaround.)
Maybe, but it is a much better solution than toggling their
visibility.
[...]
>
Does anyone have a piece of code where, given two control objects as
passing parameters, it returns true or false in regards to them
overlapping or not?
There is no need to determine if they overlap - cover all of them with
iFrames. You can create all the iFrames at any time before dragging
starts, you might be able to put them in the source HTML but likely
script is better, then just toggle their display property (use a class
and CSS) when dragging starts and again when it ends. If the iFrames
have no visible style, they're invisible, the user will never know
you've done it.

During testing/debugging, give the iFrames a background colour to help
with making sure they're in the right spot.
--
Rob

Oct 4 '07 #3
On Oct 4, 2:00 pm, David Mark <dmark.cins...@gmail.comwrote:
On Oct 3, 10:17 pm, RobG <rg...@iinet.net.auwrote:
On Oct 4, 8:45 am, David Mark <dmark.cins...@gmail.comwrote:
On Oct 3, 2:26 pm, Jay <Jay.Pomp...@gmail.comwrote:
[...]
Naturally the customer doesn't like this. I experimented a little with
the IFrame solution, but did not have much luck. It seems easier now
That Iframe "solution" is not a solution (it is an ugly workaround.)
Maybe, but it is a much better solution than toggling their
visibility.

Hardly. Creating a bunch of non-standard "dummy" elements and then
going through all of the mess of positioning them
That can be done in a few lines of code with a reasonable position
function. The one at Javascript Toolbox seems to do the job OK.

is not a better
solution than simply hiding the inputs during the drag operation.
Clearly the inputs are not drop targets, so there is no reason they
need to be visible while dragging.
Yeah, a bit of playing shows IE makes life tough. I normally only use
iFrames under other elements, I'd forgotten that you can't make them
pretty in IE.

How about a single iFrame under the drag object that moves with it?
Then there's no need to find and hide the selects - I just hate the
idea the selects flashing on and off.
--
Rob

Oct 4 '07 #4
Jay
Thanks for all your 'wonderful' insight...Much obliged.

Oct 4 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: axion_sa | last post by:
Hi, What I have is a booking table, and when updating/inserting I need to ensure that there are no date/time overlaps. The problem I'm having is that while the following script works for...
18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
17
by: No One | last post by:
Is there a way to keep a control centered inside a form without having to recalculate everytime the form is resized?
6
by: Tom McLaughlin | last post by:
How can I determine the numbers of lines of text that are visible in a textbox? Tom
3
by: Developer in California | last post by:
I am working on developing a generic Web framework using Master Pages in ASP.NET 2.0. What I have done is created a PageRenderer class which has a public method which will retrieve the path of the...
1
by: antonyliu2002 | last post by:
I am using the server side Toggle Controls implemented by Jos (cf: http://www.codeproject.com/aspnet/ToggleControls.asp), which is pretty cool, if you wanna toggle controls. On my web page, I...
4
by: dBNovice | last post by:
Hello all, i will definitely appreciate any help I can get on this.... I have a db that has 3 tables and 3 respective forms: task, subtask and element. Subtask is a subform of task. Element is...
2
by: jaleel | last post by:
I have an aspx page containing a menu and some other controls including dropdown list.The problem is when i hover the mouse on menu control it displays all menu items. But the part where dropdown...
1
by: prpradip | last post by:
In my application ListView is inside panel (XP theme enable), item text in the ListView control overlaps other items in small icon view. The items are drawn as if aligned to a grid and this causes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.