Leaflet.draw delete last point - leaflet

I'm trying to create a set of buttons to replace the default L.Control.Draw buttons (only for a polyline, in my case). Using this answer
I have been able to replicate Draw, Edit, Delete and their associated 'Cancel' and 'Save' buttons. What I cannot figure out is how to replicate the 'Delete last point' function for the Draw button.

Call the deleteLastVertex method on your draw instance:
var drawPolyline = new L.Draw.Polyline(map, drawControl.options.polyline).enable();
drawPolyline.deleteLastVertex();

Related

In LibreOffice Calc change the size of a shape by clicking it

I have several shapes in LO Calc and I need those shapes to change their sizes when they are mouse clicked: the first click enlarges the shape, the second click restores the original size.
I'm trying to do this with a macro assigned to those shapes. My problem and my question: how to determine within a macro which shape has been clicked?
I know how to get the current selected shape:
dim doc as object
doc = ThisComponent
someVar = doc.CurrentSelection...
But a shape when clicked is not getting selected and this method is not working.
I tried to add a parameter for the event object to the macro:
sub ChangeSize( oEvent )
But this produces a message about wrong number of parameters.
Is there a way to detect the caller of a macro in LO Basic? Or maybe another way to implement size changing with a mouse click?
P.S. One can use a separate button for calling the macro and click this button after selecting the needed shape, but this way is less convenient.
EDIT: As I guessed below in the comments, the described task can be solved via the mouse and shape coordinates. The key points for the solution I found here:
How to get Document-Coordinates from a Mouse Click in an OpenOffice BASIC Macro
Instead of detecting the caller, assign a different one-line macro for each shape clicked event.
Sub ShapeClickedA
ChangeSize("ShapeA")
End Sub
Sub ShapeClickedB
ChangeSize("ShapeB")
End Sub
Related: LibreOffice macro showing simple TextBox shape
P.S. After answering, I realized you asked the linked question as well. How is this different, and is the other answer not satisfactory?

Coordinating overobj and toolbar buttons to set pointer in Matlab

This post shows how to use the overobj function to set the pointer to change over the axes part of a gui. The problem is that this will override the pointer shape set by the zoom or pan toolbar buttons. I can test for various toolbar buttons being on like this:
if (strcmp(handles.zoom.State, 'off'))
obj_han=overobj('axes');
if ~isempty(obj_han)
set(handles.figure1,'Pointer','cross');
else
set(handles.figure1,'Pointer','arrow');
end
end
But that requires adding a new test for every tool button in the toolbar, which seems like a formula for error. How does zoom, for example, set the pointer? Is there a better way to integrate changing the pointer with the way the toolbar buttons make the change?
You could use the undocumented uimode and uimodemanager to get the current uimode and if the current uimode is empty, then none of the tools are active.
manager = uigetmodemanager(gcf);
% Only alter the pointer if the CurrentMode is empty
if isempty(manager.CurrentMode)
if ~isempty(obj_han)
set(handles.figure1, 'Pointer', 'cross')
else
set(handles.figure1, 'Pointer', 'arrow')
end
end
I would retrieve the uimodemanager outside of your callback and pass it explicitly to the callback so you don't have to retrieve it every time.

uimenu buttons remain pressed and trigger also other menus by just sliding over them: pushbutton behaviour desired

I implemented various uimenus in my uitable but there appears a very annoying behaviour.
function createUItable
h = figure
...
uimenu(h,'Label','MenuButton','Callback',#someAction)
end
%---------
function someAction(~,~)
%some action
end
But after executing the callback function, the menu button remains pressed and highlighted and not even that, when I slide over the next menu button, this one is triggered also!
This behaviour was also described at Matlab Central, but without solution.
I tried the suggested:
function someAction(~,~)
%some action
set(gcbo,'Enable','off')
drawnow
set(gcbo,'Enable','on')
end
which does not change anything. set(gcbo,'Enable','off') alone would solve the sliding problem, but also disables the whole button, what I don't want.
I also tried to use the 'Checked','Visible' and 'Interuptible' property without success.
This problem must be known, any hints?
I also thought about using uicontrol instead of uimenu and use a pushbutton, but I don't get it work.
Edit: when I put my menubutton into a submenu it works perfect:
button = uimenu(h,'Label','MenuButton');
uimenu(button,'Label','MenuButton','Callback',#someAction)
Edit2:
A pushbutton works also, but how could I place it into the menubar?
I guess MATLAB implementation is this way, because setting a callback at the top-level menu is very odd.
Naturally in GUI's (not only MATLAB), when you click the top-level menu (like "File", "Edit", etc.) the standard behaviour is, that a submenu pops open rather than an immediate action being executed.
So you should only use the top-level callback to e.g. dynamically create/modify the associated submenus.
I think there are two alternatives to go:
1) If you'd like to stick to that manner (one, always-visible button-like element), then you should rather use the toolbar via a uipushtool:
hToolbar = uitoolbar(parentFigure);
uipushtool(hToolbar, 'ClickedCallback', #someAction);
This does not have the 'Label' property though, so you'll have to work with 'CData' and may be a 'TooltipString'.
2) Create a top-level menu that contains your actual action-menu:
topMenu = uimenu(parent, 'Label', 'Actions');
uimenu(topMenu, 'Label', 'MenuButton', 'callback', #someAction)
From the general point of view on GUI design, both alternatives have the benefit of being the more commonly used style, thus being more intuitive to any user.
I found an interesting work-around for this problem while keeping the callback in the TOP menu. Turns out that using the uistack function released focus from the menu item so in the top-level menu callback, I placed
uistack(hObj,'down');
uistack(hObj,'up');
drawnow;
Which does nothing to the actual ordering but releases the menu items' focus.

Extjs4 drag and drop grid after grid.removeAll()

I have two grid-panels to drag from grid1 and drop on grid2, and a reset button with this handler function:
handler: function(){
//refresh source grid
Ext.getCmp('grid1').getStore().load();
//purge destination grid
Ext.getCmp('grid2').removeAll();
}
All works good, but when I click on the reset button, I can't drop on grid2 again!
You're calling the removeAll() method from the grid component here, not the store... which probably breaks the grid.
You should try with:
Ext.getCmp('grid2').getStore().removeAll();

add/delete listgrid by clicking +/- image button

I need a listgrid with +/- button so that I can use these buttons for adding or deleting list grid.
ListGrid listGrid = new ListGrid();
listGrid.setWidth(230);
listGrid.setHeight(224);
listGrid.setDataSource(coursesDS);
listGrid.setCanDragRecordsOut(true);
listGrid.setDragDataAction(DragDataAction.COPY);
In this way only listgrid will be created, but is there any implicity functionality for increment listgrid by providing button specific to listgrid?
Or I need to create explicitly image button and have to write code so that I can add number of listgrids when click on image(add) button?
Please help. Thanks.
Regarding the "-" icon:
listGrid.setCanRemoveRecords(true);
Creates an additional rightmost column with "-" icon to remove the current row of the listGrid.
The closest I could find to "+" is in this example:
http://www.smartclient.com/smartgwt/showcase/#grid_editing_new_row
listGrid.startEditingNew();
in the example the line is executed from onClick function inside ClickHandler for additional button.