[OpenLayers-Users] Textfield Event Handling in a Custom Control
Michael Hampton
javamike9 at yahoo.com
Mon Dec 14 12:16:23 EST 2009
I am going to try this again, and include the relevant code this time in the post.
How can I enable default event handling for a textfield input in a custom control?
When I place a textfield into a control on the map, it does not receive mouse events or keyboard events.
How can I make the textfield receive these events and handle them as it normally would?
Any help greatly appreciated.
This is example of what I am talking about: http://javamike9.webs.com/oltextControl.htm
Here is the (very simple) javascript portion of the problem:
OpenLayers.Control.TextFieldControl = OpenLayers.Class(OpenLayers.Control,
{
draw: function() {
OpenLayers.Control.prototype.draw.apply(this, arguments);
var element = document.createElement('div');
element.className = this.displayClass + 'Element';
var inputElement = document.createElement('input');
inputElement.type='text';
inputElement.value='test';
element.appendChild(inputElement);
//element.innerHTML = "<input type='text' value='test'></input>";
this.div.appendChild(element);
return this.div;
},
CLASS_NAME: 'OpenLayers.Control.TextFieldControl'
});
function init()
{
var map = new OpenLayers.Map( 'map' );
var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0",
{layers: 'basic'}
);
map.addLayer(layer);
var myCustomControl = new OpenLayers.Control.TextFieldControl();
map.addControl(myCustomControl);
map.zoomToMaxExtent();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091214/d02e1f46/attachment.html
More information about the Users
mailing list