Updates and fixes
- adding IsFirstHandler to allow controls to skip Actions which has been invoked already (i.e. due to navigation) - adding Hidden method to ButtonGrid to fix re-rendering Buttons after opening a Modal form and comming back - improving and fixing the Cleanup method for ButtonGrid to prevent "Keyboard jumping" for ReplyKeyboard on mobile devices. - renaming some old *Result objects to *EventArgs for more clear definitions
This commit is contained in:
@@ -49,7 +49,6 @@ namespace TelegramBotBase.Controls
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return m_eKeyboardType;
|
||||
}
|
||||
set
|
||||
@@ -111,6 +110,8 @@ namespace TelegramBotBase.Controls
|
||||
if (this.KeyboardType != eKeyboardType.ReplyKeyboard)
|
||||
return;
|
||||
|
||||
if (!result.IsFirstHandler)
|
||||
return;
|
||||
|
||||
var button = ButtonsForm.ToList().FirstOrDefault(a => a.Text.Trim() == result.MessageText);
|
||||
|
||||
@@ -132,6 +133,9 @@ namespace TelegramBotBase.Controls
|
||||
if (result.Handled)
|
||||
return;
|
||||
|
||||
if (!result.IsFirstHandler)
|
||||
return;
|
||||
|
||||
await result.ConfirmAction();
|
||||
|
||||
//Find clicked button depending on Text or Value (depending on markup type)
|
||||
@@ -247,6 +251,14 @@ namespace TelegramBotBase.Controls
|
||||
|
||||
}
|
||||
|
||||
public override async Task Hidden(bool FormClose)
|
||||
{
|
||||
//Prepare for opening Modal, and comming back
|
||||
if (!FormClose)
|
||||
{
|
||||
this.Updated();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tells the control that it has been updated.
|
||||
@@ -256,21 +268,35 @@ namespace TelegramBotBase.Controls
|
||||
this.RenderNecessary = true;
|
||||
}
|
||||
|
||||
|
||||
public async override Task Cleanup()
|
||||
{
|
||||
if (this.MessageId == null)
|
||||
return;
|
||||
|
||||
await this.Device.DeleteMessage(this.MessageId.Value);
|
||||
|
||||
this.MessageId = null;
|
||||
|
||||
if (this.KeyboardType == eKeyboardType.ReplyKeyboard && this.HideKeyboardOnCleanup)
|
||||
switch (this.KeyboardType)
|
||||
{
|
||||
await this.Device.HideReplyKeyboard();
|
||||
case eKeyboardType.InlineKeyBoard:
|
||||
|
||||
await this.Device.DeleteMessage(this.MessageId.Value);
|
||||
|
||||
this.MessageId = null;
|
||||
|
||||
break;
|
||||
case eKeyboardType.ReplyKeyboard:
|
||||
|
||||
if (this.HideKeyboardOnCleanup)
|
||||
{
|
||||
await this.Device.HideReplyKeyboard();
|
||||
}
|
||||
|
||||
this.MessageId = null;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user