texteditor.gadget notifyevent

This forum is for general developer support questions.
Post Reply
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

texteditor.gadget notifyevent

Post 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?
Workbench Explorer - A better way to browse drawers
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 530
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: texteditor.gadget notifyevent

Post 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.
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: texteditor.gadget notifyevent

Post 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....
Post Reply