Thread

Index > Scribe > Context menu script anomalies
Author/Date Context menu script anomalies
Scott
19/11/2017 11:10pm
I've added a context menu to adjust the label and colour for the current mail.
For some reason it pops open a new filter box after it adjusts the label and colour. Is this a bug in Scribe as I'm not seeing anything in the script that would do this? Furthermore, I'd like to prompt the user for the text to will be assigned to the label. How do I prompt for text?

Here's the code:

function MarkAsPaid(App, Thing, Menu)
{
  if (Thing.Type != 0xaaff0001)
  {
    Print("Error: Not an email.\n");
    return false;
  }
  Print("Marking as paid.");
  Thing.Colour = 0;
  Thing.Label = "Paid";

  return false;
}



function CreateBillsMenu(App, Thing, Menu)
{
  if (Thing.Type == 0xAAFF0001)
  {
    Sub = GMenuAddSubmenu(Menu, "Mark bills", Menu.Length - 2);
    if (Sub)
    {
      MailFrom = Thing.From.Email;
      GMenuAddItem(Sub, -1, "as paid: '" + MailFrom + "'", -1, "MarkAsPaid", 3001);
    }
  }
}

function Main(App)
{
  if (!AddCallback("OnThingContextMenu", "CreateBillsMenu"))
    MsgBox(App, "Couldn't add CreateBillsMenu");

  return 1;
}
fret
20/11/2017 10:22am
See the last argument to 'GMenuAddItem'? That's the menu ID. Because you copied the code from 'Mail Filters Menu.script' there is an existing menu for 3001:

GMenuAddItem(Sub, -1, "Text.." + MailFrom + "'", -1, "CreateFromFilter", 3001);

So it's calling CreateFromFilter, cause it was added first.

Change the ID to something else and it works as expected.
Scott
20/11/2017 11:48pm
That fixed the problem with the filter popping up.

How do I prompt for text to use for the label?
fret
21/11/2017 7:23am
How do I prompt for text to use for the label?
Use this function:
string GetInputDlg(parent_wnd, initial_value, msg, title, is_password);

Asks the user for input using a dialog.

Arguments:
parent_wnd: The handle of the parent window.
initial_value: The initial value in the editbox field.
msg: A message above the editbox.
title: The title of the dialog.
is_password: True if you want the editbox content obsured by dot characters.

Returns:
A string containing what the user entered.
Scott
21/11/2017 7:31am
Is there any way to pull text out of the clipboard contents?
fret
21/11/2017 8:27am
Is there any way to pull text out of the clipboard contents?
Not at the moment.
Scott
26/11/2017 12:22am
The provided script gives the following error:
Grp has: (null)
ListContacts.script:13 IDomGet warning: Unexpected Dom member 'Groups'.

The last line appears several times in each instance.
I am unable to get rid of this error.
Scott
26/11/2017 4:00am
Whoops, posted to the wrong thread, reposted in correct thread.
fret
05/12/2017 11:22pm
Is there any way to pull text out of the clipboard contents?
The app object will have the following methods in the next build:
String App.GetClipboardText();
Bool App.SetClipboardText(String Text);


Reply