Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Questions about context menu of nodes (Read 575 times)
dpru2
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 19
Joined: Feb 2nd, 2021
Questions about context menu of nodes
Dec 20th, 2022 at 9:08pm
Print Post  
I have a few questions about the context menu of nodes, and also related to editing text in nodes.

Based on the documentation at this link (https://www.mindfusion.eu/onlinehelp/xamarin.diagram/index.htm), I can prevent a user from editing the text of a node by handling the NodeTextEditing event on a diagram object. However, beyond that piece of information, no other information is provided. I've gone ahead and implemented an event handler, but it isn't clear on exactly how to implement the event handler so to prevent text editing.

My intuition would be to set a flag or return some boolean value to the caller, but the function doesn't have a return value, and there isn't an obvious flag to set anywhere. Any help in this regard would be appreciated.

Next question: is there a way to customize the context menu itself? Right now when I do a "long press" on a node, the context menu pops up as 3 icons: one to the left (a text editing icon), one above the node (a trash/delete icon), and one to the right (a paperclip icon - I haven't tested what it does). I'd like to customize what icons show up there, or maybe even have a dialog pop up or a new screen slide in when the user tries to open the context menu.

Edited:
More questions:

Currently, when in "text editing mode" for a node, it basically covers the entire node with a dark green rectangle. Is there any way to change this?

Also, the font size can seem quite small while editing. I know how to change the font size for existing text in a node (set the FontSize property in the ShapeNodeStyle object of the Style property on the node), but what about changing the font size of the text during editing? Is there a way to do so?

Also, is there a way to make it so that the text does not "wrap" if it is over a certain length? My solution for now is to inspect the incoming text that a user has entered, and if it is "too long" then I will modify the text to make it shorter.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3154
Joined: Oct 19th, 2005
Re: Questions about context menu of nodes
Reply #1 - Dec 21st, 2022 at 12:07pm
Print Post  
You should be able to cancel the text edit by setting args.Cancel = true;

Quote:
Next question: is there a way to customize the context menu itself?


The control raises RadialMenuCreated, where you should be able to customize the args.Menu object (https://mindfusion.eu/Forum/YaBB.pl?num=1591174570).

Quote:
Currently, when in "text editing mode" for a node, it basically covers the entire node with a dark green rectangle. Also, the font size can seem quite small while editing.


That's instance of DiagramEditor : Xamarin.Forms.Editor class. Try customizing the font through a global style in the Xaml for respective TargetType. The color seems hard-coded at this time.

Quote:
is there a way to make it so that the text does not "wrap"


Try setting WrapText = false in node.TextFormat;

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3154
Joined: Oct 19th, 2005
Re: Questions about context menu of nodes
Reply #2 - Jan 2nd, 2023 at 6:12am
Print Post  
New build here removes the default green background from editor:
https://www.nuget.org/packages/MindFusion.Diagramming.Maui/

You can now customize the color through Xaml style:
Code
Select All
<ContentPage.Resources>
	<ResourceDictionary>
		<Style TargetType="diag:TextEditor">
			<Setter Property="BackgroundColor" Value="Yellow" />
			<Setter Property="TextColor" Value="Blue" />
		</Style>
	</ResourceDictionary>
</ContentPage.Resources>
 



We've also implemented EnterInplaceEditMode / LeaveInplaceEditMode events from our other platforms (https://www.mindfusion.eu/onlinehelp/wpfdiagram/E_MindFusion_Diagramming_Wpf_Dia...) allowing for another extension point:

Code
Select All
diagram.EnterInplaceEditMode += OnEnterInplaceEditMode;

void OnEnterInplaceEditMode(object sender, InPlaceEditEventArgs e)
{
	e.TextEditor.BackgroundColor = Colors.Red;
} 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint