[ 10 posts ]

Alvin

  • Username: Alvin
  • Joined: Fri Mar 05, 2010 1:56 am
  • Posts: 2
  • Offline
  • Profile

YUI Drag and Drop text Box issue in firefox

Post Posted: Sun Mar 07, 2010 5:14 am
+0-
Hi
When i drag and drop the input text box the focus is not gained or it is not editable upon mouse click in firefox.
In regards to this i wrote a function to set the focus but then once i drag the textbox it is still not gaining the Focus.

Dav Glass

  • Username: davglass
  • Joined: Thu Aug 28, 2008 9:28 am
  • Posts: 2088
  • Location: Marion, IL, US
  • Twitter: davglass
  • GitHub: davglass
  • Gists: davglass
  • IRC: davglass
  • Offline
  • Profile

Re: YUI Drag and Drop text Box issue in firefox

Post Posted: Sun Mar 07, 2010 11:51 am
+1-
You shouldn't Drag form elements, you need to make the container of the form element draggable and drag it that way. The issue is that DD listens for a mousedown to move the element & that mousedown traps the focus of an input.

You might also want to use a handle to drag the element instead of the element itself.

Alvin

  • Username: Alvin
  • Joined: Fri Mar 05, 2010 1:56 am
  • Posts: 2
  • Offline
  • Profile

Re: YUI Drag and Drop text Box issue in firefox

Post Posted: Sun Mar 07, 2010 11:46 pm
+0-
Hi
When i drag the textbox the mouse focus is not happening upon click but when i drag the other one then previous one gets the focus upon mousedown(click).



<input type="text" name="property-primary" id="createCustomSearch-<%= searchCategoryId %>-property-<%= searchPropertyId %>-field" class="field textField"

onclick="gainFocus('createCustomSearch-<%= searchCategoryId %>-property-<%= searchPropertyId %>-field');" />

<input type="text" name="property-<%= searchPropertyTypeId %>" id="createCustomSearch-<%= searchCategoryId %>-property-<%= searchPropertyTypeId %>-field"
onclick="gainFocus('createCustomSearch-<%= searchCategoryId %>-property-<%= searchPropertyTypeId %>-field');" />



function gainFocus(x){

document.getElementById(x).focus();
}

DragDrop.js:-----------
/**
* Internal function to handle the mousemove event. Will be invoked
* from the context of the html element.
*
* @TODO figure out what we can do about mouse events lost when the
* user drags objects beyond the window boundary. Currently we can
* detect this in internet explorer by verifying that the mouse is
* down during the mousemove event. Firefox doesn't give us the
* button state on the mousemove event.
* @method handleMouseMove
* @param {Event} e the event
* @private
* @static
*/
handleMouseMove: function(e) {

var dc = this.dragCurrent;
if (dc) {

// var button = e.which || e.button;

// check for IE mouseup outside of page boundary
if (YAHOO.util.Event.isIE && !e.button) {
alert("Inside IE Check")
this.stopEvent(e);
return this.handleMouseUp(e);
}

if (!this.dragThreshMet) {
var diffX = Math.abs(this.startX - YAHOO.util.Event.getPageX(e));
var diffY = Math.abs(this.startY - YAHOO.util.Event.getPageY(e));
if (diffX > this.clickPixelThresh ||
diffY > this.clickPixelThresh) {
this.startDrag(this.startX, this.startY);
}
}

if (this.dragThreshMet) {
dc.b4Drag(e);
if (dc) {
dc.onDrag(e);
}
if (dc) {
this.fireEvents(e, false);
}
}

this.stopEvent(e);
}
},

ariester

  • Joined: Tue Mar 16, 2010 1:28 pm
  • Posts: 4
  • Offline
  • Profile

Re: YUI Drag and Drop text Box issue in firefox

Post Posted: Tue Mar 16, 2010 1:50 pm
+0-
I'm actually running into the same issue. I'm trying to allow users to dynamically build a data table. Please forgive the HORRIBLE UI for the moment. I haven't gotten around to styling it yet.

Image

The gray boxes are list items (lis) that have been made draggable using an extended version of the YUI DDProxy class that is based very closely on one of the examples given on the YUI website. This would make the li, which I would consider the container, draggable and not the form element itself. The select box and check boxes work just fine but the text input is still borked. I really don't want to implement handles if I don't have to. Are there any common "gotchas" that I may have fallen into? I can post code if needed.

Joe Developer

  • Username: JoeDev
  • Joined: Sat May 09, 2009 12:54 am
  • Posts: 73
  • Twitter: joe_developer
  • IRC: unomi
  • Offline
  • Profile

Re: YUI Drag and Drop text Box issue in firefox

Post Posted: Tue Mar 16, 2010 7:43 pm
+0-
Have you tried the 3.1pr ?

ariester

  • Joined: Tue Mar 16, 2010 1:28 pm
  • Posts: 4
  • Offline
  • Profile

Re: YUI Drag and Drop text Box issue in firefox

Post Posted: Wed Mar 17, 2010 7:47 am
+0-
Not yet. I'll try that and post back. Thanks for the suggestion

ariester

  • Joined: Tue Mar 16, 2010 1:28 pm
  • Posts: 4
  • Offline
  • Profile

Re: YUI Drag and Drop text Box issue in firefox

Post Posted: Wed Mar 17, 2010 3:08 pm
+0-
I took the example at http://developer.yahoo.com/yui/3/examples/dd/list-drag_clean.html and replaced the inner html of all the lists item with an input box.

Image

It almost works.

Click on the input box in blue #1. Type "hello." Move blue #1 into the yellow list. Attempt to type in the input box in blue #1 but cannot. Move yellow #1. Successfully type "world" in input box in blue #1.

It still doesn't release the focus correctly. I need to move something else before I can type in this box again. That's not user friendly at all. Is there a way I can cheat and make the browser think that something else was dragged instead? Maybe by adding something into the Y.DD.DDM.on(drag:drophit ) function?

ariester

  • Joined: Tue Mar 16, 2010 1:28 pm
  • Posts: 4
  • Offline
  • Profile

Re: YUI Drag and Drop text Box issue in firefox

Post Posted: Wed Mar 17, 2010 3:23 pm
+0-
haha! Ghetto hack for the win.

I added this code and now it works
Code:
var inputs = Y.Node.all('input');
   inputs.each(function(v, k) {
      Y.on("click", function(e){e.target.focus()}, v);
    });

w.duff

  • Joined: Sun Nov 14, 2010 7:42 pm
  • Posts: 1
  • Offline
  • Profile

Re: YUI Drag and Drop text Box issue in firefox

Post Posted: Sun Nov 14, 2010 7:47 pm
+0-
Great hack, I think this hack is useful for my page.

thanks
ariester wrote:
haha! Ghetto hack for the win.

I added this code and now it works
Code:
var inputs = Y.Node.all('input');
   inputs.each(function(v, k) {
      Y.on("click", function(e){e.target.focus()}, v);
    });

pravin

  • Username: pravinthakare
  • Joined: Tue Jan 04, 2011 10:41 pm
  • Posts: 1
  • Offline
  • Profile

Re: YUI Drag and Drop text Box issue in firefox

Post Posted: Tue Jan 04, 2011 10:59 pm
+0-
ariester wrote:
haha! Ghetto hack for the win.

I added this code and now it works
Code:
var inputs = Y.Node.all('input');
   inputs.each(function(v, k) {
      Y.on("click", function(e){e.target.focus()}, v);
    });



hi ariester

can u tell me where to put this code ,am new for YUI and first time implementing the DD .i got ur code but having trouble with Y.Node

plz reply as soon as possible
  [ 10 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum