Page 1 of 1

texteditor.gadget notifyevent

PostPosted: Sun Aug 19, 2018 9:55 pm
by mritter0
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?

Re: texteditor.gadget notifyevent

PostPosted: Mon Aug 20, 2018 7:16 am
by salass00
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.

Re: texteditor.gadget notifyevent

PostPosted: Mon Aug 20, 2018 9:51 pm
by broadblues
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....