question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to open menu via code?

See original GitHub issue

Hi,

I have the following menu:

    const projectEdit = new TelegrafInlineMenu(
        async ctx => await projectController.DisplayProjectDetails(ctx, ctx.match[1])
    );
    projectEdit.simpleButton(ctx => ctx.i18n.t('editName'), 'EDIT_PR_NAME', {
        doFunc: async ctx => {
            await ctx.scene.enter('projectName-wizard');
        }
    });

this menu simply allow the user to edit the name of the project through ctx.scene.enter('projectName-wizard'). So when the Wizard-Scene is completed, that scene print the following message:

ctx.reply(ctx.i18n.t('projectUpdated'));

and then:

return pr;

where pr is the object which contains the project. I get the following result:

[PROJECT EDIT MENU] => EDIT PROJECT NAME INSERT NEW NAME: foo Project updated!

Is possible go back to [PROJECT EDIT MENU], and so reloading the project details as did by: elegrafInlineMenu(async ctx => await projectController.DisplayProjectDetails(ctx, ctx.match[1]));?

How can I do this?

Thanks in advance.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
EdJoPaTocommented, Jun 7, 2019

A working example is within the tests: https://github.com/EdJoPaTo/telegraf-inline-menu/blob/4120680680893ceaf7e50f696b9a4b6737825e46/test/reply-menu-middleware.ts#L59-L76

My approach of solving things is to simplify and remove as much as possible in my experimental environment. If there it is not fitting on one screen there is to much going on to understand. 😃

When I have more time I will take a look but I will only do the same: simplify everything 😉 I hope I could help 😃

1reaction
EdJoPaTocommented, Jun 10, 2019

hide prevents a button to be seen or when still existing to be clicked.

If you want to locked button feature you could do it yourself like this:

function isButtonLocked(ctx) { return true/false }

menu.simpleButton(ctx => `${isButtonLocked(ctx) ? '🔒' : '🔓'} my text`, 'action', {
  doFunc: ctx => {
    if (isButtonLocked(ctx) {
      return ctx.answerCbQuery('currently locked!')
    }

    return ctx.answerCbQuery('currently unlocked :)')
  }
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

Application Menu Example & Code - W3C
Application Menu Example & Code. in Menus Tutorial. Example. File. New; Open; Print. Edit.
Read more >
Menus - Android Developers
For all menu types, Android provides a standard XML format to define menu items. Instead of building a menu in your activity's code,...
Read more >
Android: Open menu programmatically - Stack Overflow
If you are using customized toolbar in your app, then the following way will be useful, new Handler().postDelayed(new Runnable() { @Override public void ......
Read more >
How to Create Android Popup Menu Programmatically and ...
Hi and welcome to another tutorial from CodingDemos :) In this tutorial, you will learn how to create Android popup menu or floating...
Read more >
Popup Menu in Android With Example - GeeksforGeeks
<? xml version = "1.0" encoding = "utf-8" ?> ... In the MainActivity.java file, we will get the reference of the Button and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found