QCalendar renders outside QPanel

thread: 8 messages  |  last: about 3 years ago  |  started: friday, august 8, 2008, 7:42 am pdt


#1  |  elmovil (Chile) Chile
Friday, August 8, 2008, 7:42 AM PDT

hi, i have a qform with 2 qpanels, in one of them i show a qcalendar control but it render outside the qpanel, in the bottom of the qform.

What could it be? any suggestions?

#2  |  enzo - Eduardo Garcia (San Jos) Colombia
Friday, August 8, 2008, 7:50 AM PDT

Hello elmovil

Could you upload your code to qform and template you use to render, in my experience this behavior happens when you render in a place where html is generated incorrectly.


nos vemos

enzo

#3  |  elmovil (Chile) Chile
Friday, August 8, 2008, 7:54 AM PDT

thnx for the reply enzo, i think got the problem...
it's strange... the panel have a scroll and the qcalendar shows at the right place but when the control is hidden down the panel the calendar appears at the initial place of the control in the form and not at the place when i hit the button

if i render the qcalendar in the top of the panel it's all OK, the problem is when render exeeding the panel height

it's strange to explain, hope you understand me

#4  |  enzo - Eduardo Garcia (San Jos) Colombia
Friday, August 8, 2008, 7:59 AM PDT

Hello elmovil

Well I don't really understand you, maybe could you upload images in some place and link here.

if you want, you would add my contact in M S N : jegarto at hortmail dot com to talk in spanish :P

best regards

enzo

#5  |  krusty (Vancouver, BC) Canada
Wednesday, October 29, 2008, 4:11 PM PDT

I see this behaviour when I try to use QCalendar in QPanels.

The calendar dialog box shows up in a completely different place than it should (right beside the QDateTimeTextBox on my QPanel).

The offending code is this in calendar.js:

        objControl.showCalendar = function() {
            var strPositionArray = this.wrapper.getAbsolutePosition();
            this.calendarPane.style.left = this.offsetLeft + "px";
            this.calendarPane.style.top = this.offsetTop + "px";
            this.calendarPane.style.position = "absolute";
            this.calendarPane.style.zIndex = 10;
            this.calendarPane.style.display = "block";
            this.drawCalendar(0, 0);
        };

this.offsetLeft & this.offsetTop values are meant to be relative to the upper left-hand corner of the QPanel.  However, they are taken to be relative to the upper left-hand corner of the entire page.

That explains why the calendar shows up somewhere unexpected.  However, as i'm not a js expert, i'm not exactly sure how to fix this.

James

#6  |  krusty (Vancouver, BC) Canada
Wednesday, October 29, 2008, 4:25 PM PDT

I hate to reply to my own post, but here's a solution I found to this:

        objControl.showCalendar = function() {
            var strPositionArray = this.wrapper.getAbsolutePosition();
            this.calendarPane.style.left = strPositionArray['x'] + "px";
            this.calendarPane.style.top = strPositionArray['y'] + "px";
            this.calendarPane.style.position = "absolute"; 
            this.calendarPane.style.zIndex = 10;
            this.calendarPane.style.display = "block";
            this.drawCalendar(0, 0);
        };

It seems the strPositionArray variable is populated at the start of this function, but is never used.  I replaced the offsetLeft & offsetTop variables with values from the strPositionArray array.

This placed the QCalendar in the right place.

This solution works for me, but I do not know if it affects other usages of QCalendar (on a QForm directly, for example).

James

#7  |  Tom Ierna (Tampa, FL) United States of America
Monday, January 5, 2009, 7:33 PM PST

This patch seems to have made it into the QCubed fork. However, it doesn't seem to work for everything.

I've got quite a few Dialog Boxes which contain QCalendars. They render exactly the number of pixels low and right as the distance between the top left corner of the browser window the top left corner of the Dialog Box.

To fix it, in the calendar.js, I've replaced:

This:

var strPositionArray = this.wrapper.getAbsolutePosition();
this.calendarPane.style.left = strPositionArray['x'] + "px";
this.calendarPane.style.top = strPositionArray['y'] + "px";

with this:

this.calendarPane.style.left = this.dateTimeTextBox.wrapper.offsetLeft + "px";
this.calendarPane.style.top = this.dateTimeTextBox.wrapper.offsetTop + this.dateTimeTextBox.offsetHeight + "px";

Caveats:
- I have only tested this to work in the most recent Safari and Firefox.
- This doesn't fix the underlying problem with getAbsolutePosition, which seems to be including the position of some wrapper element it shouldn't.
- This doesn't fix the problem of the QCalendar staying in the same relative place in the browser window if the user resizes when the QCalendar is Visible.
- This needs to be fixed in several places if you use Shannon Pekary's QDateTimeComposite. (http://www.qcodo.com/downloads/item.php/192)

#8  |  Basilieus (Tucson,AZ) United States of America
Wednesday, January 7, 2009, 12:24 PM PST

This is now tracked on QCubed http://trac.qcu.be/projects/qcubed/ticket/125

A patch has been submitted.



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.