Thanks for resending.
Have you looked into the State Pattern? (This might be what you are
describing below). Effectively, you have a separate class for each
state. Eg, an EditingState, NavigationState, etc.
Each State class is responsible for processing mouse actions. Eg: When
double click is pressed, do X.
The State object is attached to a toolbar or MapPane when a button on
the toolbar is selected.
Steven M. Ottens wrote:
> Right....
>
> This will teach me to never rush an email just before you need to
> catch a train. Apparently the attachment ended up in the middle of the
> email so most of you probably didn't read further than the first line.
> Still I'd like to discuss this, so for the lazy ones here is the rest
> of the mail without binairy information :)
>
>> In my continuing quest to a nice google-like interface for mapbuilder
>> I ran into the following problem:
>>
>> I want a few 'states' for the application; right now I have a normal
>> pan/zoom/featureinfo state and a measurement state (the latter is
>> just a drawing state that calculates a distance of a line instead of
>> just creating a line). In the future I might want to create more
>> states. Just like google I don't want to have buttons for each
>> function, just for the states. This means that the mousebuttons
>> should be able to trigger different functions in a state:
>>
>> In normal pan/zoom mode I have these buttons:
>>
>> -double-left click: zoom in
>>
>> -left-drag: pan
>>
>> -scrollwheel: zoom in/out
>>
>> I want to add getFeatureInfo to the normal pan zoom mode, since I'd
>> like to keep the amount of buttons to a minimum. However since double
>> click and drag are already taken, it's hard to use single left click
>> for this. (how do you tell whether it's going to be a double click or
>> a drag instead of a single click)
>>
>> So I've decided to go for the right-mouse click.
>>
>>
>> To get this I've modified MapPaneOL.updateMouse(e):
>>
>> MapPaneOL.prototype.updateMouse = function(e) {
>>
>> // get objRef from the event originator object (e.object),
>>
>> // where it was stored as mbPane property by paint().
>>
>> var objRef = e.object.mbMapPane;
>>
>>
>> // update map pane cursor
>>
>> if (objRef.model.map.mbCursor) {
>>
>> objRef.model.map.div.style.cursor = objRef.model.map.mbCursor;
>>
>> }
>>
>> // Check if the left mouse button is used
>>
>> var isLeftClick = (((e.which) && (e.which == 1)) ||
>>
>> ((e.button) && (e.button == 1)));
>>
>> // fire Mapbuilder mouseup event
>>
>> if (isLeftClick) objRef.model.callListeners('mouseup', {evpl:
>> [e.xy.x, e.xy.y]});
>>
>> // it is a right mouse uprequest
>>
>> else objRef.model.callListeners('rightmouseup', [e.xy.x, e.xy.y]);;
>>
>> }
>>
>>
>> (also added oncontextmenu="return false" to <div mainMapPane> to
>> disable the menu)
>>
>>
>> I've modified getFeatureInfo to listen to the rightmouse up:
>>
>> this.model.addListener("rightmouseup",this.getFeatureInfo, this );
>>
>>
>> Also I separated the actual getFeatureInfo function from the control.
>> This way it is possible to trigger the getFeatureInfo request from
>> the rightmouseup event instead of the zoombox it is now.
>>
>>
>> A further benefit is that I can now switch between measurement mode
>> en getfeatureinfo mode while keeping the panzoombar and the
>> scrollwheel functionality. It doesn't do advanced mouse handling like
>> being able to drag the map whilest drawing, but that is something
>> that has to be solved on openlayers level and I believe they are
>> working on it in the advacned vector editing project.
>>
>>
>> And finally I hacked the popup function into getFeatureInfo to make
>> sure that it shows it results in a popup (eliminating the template
>> problem that has plagued us for years incidentaly) . The entire code
>> is a series of hacks so please be careful with it.
>>
>> My question are:
>>
>> Does this look like a sensible approach to get:
>>
>> a. pan/zoom/featureinfo in one 'control'/state?
>>
>> b. be able to switch between pan/zoom/featureinfo state and drawing
>> state?
>>
>> c. get getfeatureinfo produce its results in a popup?
>>
>>
>> Attached are the modified MapPaneOL.js, GetFeatureInfoPZ.js (PZ
>> stands for PanZoomBar) and the config so people can figure out how I
>> used it.
>>
>> Regards,
>>
>> Steven
>>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> ------------------------------------------------------------------------
>
> _______________________________________________
> mapbuilder-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mapbuilder-devel
>
--
Cameron Shorter
Geospatial Systems Architect
Tel: +61 (0)2 8570 5050
Mob: +61 (0)419 142 254
Think Globally, Fix Locally
Commercial Support for Geospatial Open Source Software
http://www.lisasoft.com/LISAsoft/SupportedProducts.html
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
mapbuilder-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mapbuilder-devel