Comments (5)
Which kind of keyboard are you using ? The answer depends on it. If using the ButtonGrid control it does manage everything for you.
from telegrambotframework.
But i want to handle this pressing in the Action method. How can i to do that?
from telegrambotframework.
Which kind of Keyboard are you using ? The Reply one or the Inline one? You have to use the InlineReplyKeboard to get the Action method invoked. Check Readme and Telegram documentaion.
from telegrambotframework.
Ok, but i need Reply keyboard.
I try this:
public class StartForm : AutoCleanForm
{
public StartForm()
{
Init += OnInit;
}
private async Task OnInit(object sender, InitEventArgs ev)
{
var btn = new ButtonForm();
btn.AddButtonRow(new ButtonBase(KeyboardButtons.SearchTrips, Commands.SearchTrips));
btn.AddButtonRow(new ButtonBase(KeyboardButtons.SetFilters, Commands.SetFilters));
btn.AddButtonRow(new ButtonBase(KeyboardButtons.CreateTrip, Commands.CreateTrip));
var grid = new ButtonGrid(btn)
{
KeyboardType = TelegramBotBase.Enums.eKeyboardType.ReplyKeyboard,
Enabled = true,
HideKeyboardOnCleanup = true,
ResizeKeyboard = true
};
grid.ButtonClicked += async (s, e) =>
{
FormBase form = e.Button.Value switch
{
Commands.SearchTrips => new SearchTripsForm(),
Commands.SetFilters => new SetFiltersForm(),
Commands.CreateTrip => new CreateTripForm()
};
await NavigateTo(form);
};
AddControl(grid);
}
}
- Is it a good practice?
- Where is it better to unsubscribe from ButtonClicked or is it not needed?
from telegrambotframework.
The main reason, why it didnt worked in the first place was that ReplyKeyboard does only send "Text" back. So like a normal chat message. Thats why the Action method did not get invoked.
- I would say that looks fine.
- You dont have to, but you can add it to OnClosed event so i gets unsubscribed when navigated somewhere else
from telegrambotframework.
Related Issues (17)
- Method not found: 'Void Telegram.Bot.TelegramBotClient..ctor HOT 3
- Add method to save session states directly without stopping the Bot HOT 2
- Why won't raise init and open events of forms with index less than 2? HOT 3
- How to use the repo to chat with some chat bot? HOT 12
- Exception on Calling InvokeMessageLoop on DefaultMessageLoop when there is no "userevent" HOT 4
- Keyboard Markup always is hided when navigate to next form on phone but not on desktop HOT 5
- Sample for asp.net core HOT 4
- How can i use NavigationController HOT 9
- Exception when use Calendar/Month picker HOT 1
- What different between Init and Opened event? HOT 1
- How can i serialize state of controls? HOT 6
- How session serializer works? HOT 6
- Proactively Send a Form to User HOT 11
- Improve navigation use DI and IServiceProvider HOT 1
- Sending text null check HOT 5
- ButtonGrid does ConfirmAction even when the button is not inside the datasource
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telegrambotframework.