Fixed insertion bug
This commit is contained in:
parent
d0e4de09cc
commit
b9de2cae2d
1 changed files with 9 additions and 6 deletions
|
@ -4,6 +4,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
|
|||
using CommunityToolkit.Mvvm.Input;
|
||||
using AdvancedCalculator.Models;
|
||||
using AdvancedCalculator.Services;
|
||||
using CSMic;
|
||||
|
||||
namespace AdvancedCalculator.ViewModels;
|
||||
|
||||
|
@ -43,19 +44,21 @@ public partial class MainViewModel : ViewModelBase
|
|||
|
||||
// Insert helpers for touch: appends tokens to the input box
|
||||
[RelayCommand]
|
||||
private void InsertVariable(string? variableName)
|
||||
private void InsertVariable(VariableItem variableItem)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(variableName))
|
||||
if(variableItem == null) return;
|
||||
if (string.IsNullOrWhiteSpace(variableItem.VariableName))
|
||||
return;
|
||||
InsertToken(variableName);
|
||||
InsertToken(variableItem.VariableName);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void InsertFunction(string? functionName)
|
||||
private void InsertFunction(FunctionDefinitionItem functionDefintionItem)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(functionName))
|
||||
if(functionDefintionItem == null) return;
|
||||
if (string.IsNullOrWhiteSpace(functionDefintionItem.FunctionName))
|
||||
return;
|
||||
InsertToken(functionName + "()");
|
||||
InsertToken(functionDefintionItem.FunctionName + "()");
|
||||
// Close the functions flyout after insertion for smoother UX
|
||||
IsFunctionsPanelOpen = false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue