texteditor.gadget notifyevent

This forum is for general developer support questions.

texteditor.gadget notifyevent

Postby mritter0 » Sun Aug 19, 2018 9:55 pm

GA_TEXTEDITOR_AreaMarked (BOOL)
This tag will be set to TRUE when text is marked and back to
FALSE when nothing is marked.

You can create a notifyevent with this tag and let your
cut/copy buttons become ghosted when nothing is marked.

Applicability is (OM_GET, OM_NOTIFY)


How do you set and use these events?
Workbench Explorer - A better way to browse drawers
User avatar
mritter0
 
Posts: 212
Joined: Mon Aug 25, 2014 10:41 pm
Location: Bettendorf, IA, USA

Re: texteditor.gadget notifyevent

Postby salass00 » Mon Aug 20, 2018 7:16 am

It's not supposed to be set by you. You can use the notification on the attribute to enable and disable any menu items or buttons you have that depend on an area of text being selected (Copy, Cut, a.s.o.) as appropriate.

To get notifications as idcmp messages to your window you have to set the gadget's ICA_TARGET to ICTARGET_IDCMP. In addition if you are using ReAction's window.class you have to use an idcmp hook to catch the IDCMP_IDCMPUPDATE messages.
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 504
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland

Re: texteditor.gadget notifyevent

Postby broadblues » Mon Aug 20, 2018 9:51 pm

I do something like this in my IDCMPHook for MultiEdit

Code: Select all
case IDCMP_IDCMPUPDATE:
{
    gid = 0;
    gid=GetTagData(GA_ID,0,(struct TagItem *)msg->IAddress);
    switch((gid))
    {
        case ME_GAD_EDITORGAD:
        {
             BOOL haschanged = FALSE;
.
.
.

             haschanged = GetTagData(GA_TEXTEDITOR_AreaMarked,fd->fd_CurrentFile->fn_Marked,(struct TagItem *)msg->IAddress);
              if(haschanged != fd->fd_CurrentFile->fn_Marked)
              {
             fd->fd_CurrentFile->fn_Marked = haschanged;
           SetupGadgets(me);
                  SetMEMenuState(me);
          }

.
.
.
.


Then inside those SetupGadgets() SetMEMenuState() functions I get the value of the tag like so

GetAttr(GA_TEXTEDITOR_AreaMarked,(Object *)(*editorgad_ptr),&attr);

Note the editotgad_ptr is an abstracted pointer to pointer to the editorgad to deal with my Tabbed layout having many possible editor instances you most likely need just anormal pointer to object so don;t get confused by that....
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 538
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK


Return to General Developer Support

Who is online

Users browsing this forum: No registered users and 5 guests