English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 28 May 2023, 06:19   #1
Nightfox
Registered User
 
Nightfox's Avatar
 
Join Date: Apr 2016
Location: Perth, Australia
Posts: 388
How to correctly connect BOOPSI texteditor and scroller

Hi all

I'm using the AmigaOS 3,2 NDK with its texteditor and scroller gadgets but can't seem to get the scroller to work. I have a texteditor gadget used for displaying a chat output.

I put a couple of pages of the text in the texteditor gadget to test it out. The scroller's draggable bar is at max size so it appears that it thinks all text is visible but it is not. Clicking the scroller's up arrow scrolls the texteditor all the way to the top and clicking the down arrow does also scrolls it all to the top.

Code:
	struct TagItem chatOutputMap[] = {
		{SCROLLER_Top, GA_TEXTEDITOR_Prop_First},
		{SCROLLER_Total, GA_TEXTEDITOR_Prop_Entries},
		{SCROLLER_Visible, GA_TEXTEDITOR_Prop_Visible},
		{TAG_DONE}
	};

	if ((chatOutputTextEditor = NewObject(TEXTEDITOR_GetClass(), NULL,
		GA_ID, CHAT_OUTPUT_TEXT_EDITOR_ID,
		GA_RelVerify, TRUE,
		GA_Width, CHAT_OUTPUT_TEXT_EDITOR_WIDTH,
		GA_Height, CHAT_OUTPUT_TEXT_EDITOR_HEIGHT,
		GA_ReadOnly, TRUE,
		GA_TextAttr, &chatTextAttr,
		GA_TEXTEDITOR_ImportHook, GV_TEXTEDITOR_ImportHook_MIME,
		GA_TEXTEDITOR_ExportHook, GV_TEXTEDITOR_ExportHook_Plain,
		ICA_MAP, chatOutputMap,
		TAG_DONE)) == NULL) {
			printf("Could not create text editor\n");
			return RETURN_ERROR;
	}

	struct TagItem chatOutputScrollerMap[] = {
		{GA_TEXTEDITOR_Prop_First, SCROLLER_Top},
		{GA_TEXTEDITOR_Prop_Entries, SCROLLER_Total},
		{GA_TEXTEDITOR_Prop_Visible, SCROLLER_Visible},
		{TAG_DONE}
	};

	if ((chatOutputScroller = NewObject(SCROLLER_GetClass(), NULL,
		GA_ID, CHAT_OUTPUT_SCROLLER_ID,
		GA_RelVerify, TRUE,
		GA_Width, CHAT_OUTPUT_SCROLLER_WIDTH,
		GA_Height, CHAT_OUTPUT_SCROLLER_HEIGHT,
		SCROLLER_Top, 0,
		SCROLLER_Visible, 100,
		SCROLLER_Total, 100,
		ICA_MAP, chatOutputScrollerMap,
		ICA_TARGET, chatOutputTextEditor,
		TAG_DONE)) == NULL) {
			printf("Could not create scroller\n");
			return RETURN_ERROR;
	}

	SetGadgetAttrs(chatOutputTextEditor, mainWindow, NULL, ICA_TARGET, chatOutputScroller, TAG_DONE);
Thanks so much <3
Nightfox is offline  
Old 28 May 2023, 11:12   #2
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,001
Looks ok to me.

Try to put ICA_MAP and ICA_TARGET into the same call.

And use SetAttrs instead of SetGadgetAttrs if the window is not yet opened.

There is a working example: http://thomas-rapp.homepage.t-online...ples/texted2.c
thomas is offline  
Old 28 May 2023, 12:12   #3
Nightfox
Registered User
 
Nightfox's Avatar
 
Join Date: Apr 2016
Location: Perth, Australia
Posts: 388
Thanks for that.

I made the changes and had a look at that working example but it still doesn't work

My updated code

Code:
struct TagItem chatOutputMap[] = {
		SCROLLER_ArrowDelta, GA_TEXTEDITOR_Prop_DeltaFactor,
		SCROLLER_Total, GA_TEXTEDITOR_Prop_Entries,
		SCROLLER_Top, GA_TEXTEDITOR_Prop_First,
		SCROLLER_Visible, GA_TEXTEDITOR_Prop_Visible,
		TAG_DONE
	};

	if ((chatOutputTextEditor = NewObject(TEXTEDITOR_GetClass(), NULL,
		GA_ID, CHAT_OUTPUT_TEXT_EDITOR_ID,
		GA_RelVerify, TRUE,
		GA_Width, CHAT_OUTPUT_TEXT_EDITOR_WIDTH,
		GA_Height, CHAT_OUTPUT_TEXT_EDITOR_HEIGHT,
		GA_ReadOnly, TRUE,
		GA_TextAttr, &chatTextAttr,
		GA_TEXTEDITOR_ImportHook, GV_TEXTEDITOR_ImportHook_MIME,
		GA_TEXTEDITOR_ExportHook, GV_TEXTEDITOR_ExportHook_Plain,
		TAG_DONE)) == NULL) {
			printf("Could not create text editor\n");
			return RETURN_ERROR;
	}

	struct TagItem chatOutputScrollerMap[] = {
		GA_TEXTEDITOR_Prop_DeltaFactor, SCROLLER_ArrowDelta,
		GA_TEXTEDITOR_Prop_Entries, SCROLLER_Total,
		GA_TEXTEDITOR_Prop_First, SCROLLER_Top,
		GA_TEXTEDITOR_Prop_Visible, SCROLLER_Visible,
		TAG_DONE
	};

	if ((chatOutputScroller = NewObject(SCROLLER_GetClass(), NULL,
		GA_ID, CHAT_OUTPUT_SCROLLER_ID,
		GA_RelVerify, TRUE,
		GA_Width, CHAT_OUTPUT_SCROLLER_WIDTH,
		GA_Height, CHAT_OUTPUT_SCROLLER_HEIGHT,
		TAG_DONE)) == NULL) {
			printf("Could not create scroller\n");
			return RETURN_ERROR;
	}

	SetAttrs(chatOutputTextEditor, ICA_TARGET, chatOutputScroller, ICA_MAP, chatOutputMap, TAG_DONE);
	SetAttrs(chatOutputScroller, ICA_TARGET, chatOutputTextEditor, ICA_MAP, chatOutputScrollerMap, TAG_DONE);
Nightfox is offline  
Old 05 June 2023, 18:35   #4
Nightfox
Registered User
 
Nightfox's Avatar
 
Join Date: Apr 2016
Location: Perth, Australia
Posts: 388
I don't know if this is an issue caused by using the BOOPSI window class or layouts or what but couldn't get that to work at all so I did a dirty workaround.

For both the scroller and the texteditor I added
Code:
ICA_TARGET, ICTARGET_IDCMP
to the tags and added an IDCMP hook for the window with
Code:
WINDOW_IDCMPHookBits
set to
Code:
IDCMP_IDCMPUPDATE
My hook function is as follows:

Code:
void __SAVE_DS__ __ASM__ processIDCMP(__REG__ (a0, struct Hook *hook), __REG__ (a2, struct Window *window), __REG__ (a1, struct IntuiMessage *message)) {
	switch (message->Class) {
		case IDCMP_IDCMPUPDATE:
		{
			struct TagItem *tagList = message->IAddress;
			struct TagItem *gadgetID = FindTagItem(GA_ID, tagList);
			switch (gadgetID->ti_Data) {
				case CHAT_OUTPUT_SCROLLER_ID:
					gadgetID->ti_Tag = TAG_IGNORE;
					ULONG top;
					GetAttr(SCROLLER_Top, chatOutputScroller, &top);
					SetGadgetAttrs(chatOutputTextEditor, mainWindow, NULL,
					GA_TEXTEDITOR_Prop_First, top,
					TAG_DONE);
					break;
				case CHAT_OUTPUT_TEXT_EDITOR_ID:
					gadgetID->ti_Tag = TAG_IGNORE;
					ULONG entries;
					GetAttr(GA_TEXTEDITOR_Prop_Entries, chatOutputTextEditor, &entries);
					ULONG first;
					GetAttr(GA_TEXTEDITOR_Prop_First, chatOutputTextEditor, &first);
					ULONG deltaFactor;
					GetAttr(GA_TEXTEDITOR_Prop_DeltaFactor, chatOutputTextEditor, &deltaFactor);
					ULONG visible;
					GetAttr(GA_TEXTEDITOR_Prop_Visible, chatOutputTextEditor, &visible);
					SetGadgetAttrs(chatOutputScroller, mainWindow, NULL,
					SCROLLER_Total, entries,
					SCROLLER_Top, first,
					SCROLLER_ArrowDelta, deltaFactor,
					SCROLLER_Visible, visible,
					TAG_DONE);
					RefreshGadgets(chatOutputScroller, mainWindow, NULL);
					break;
				}
			break;
		}
		default:
			printf("Unknown message class: %lx\n", message->Class);
			break;
	}
}
It's not perfect, the scroller and texteditor gadgets are a bit jittery but it is useable at least. Definitely want to have a better solution eventually
Nightfox is offline  
Old 05 June 2023, 20:11   #5
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,001
Check out my example, it works.

If you need more help, you should supply a small compilable test program which shows the issue. Then I can try to fix it.
thomas is offline  
Old 05 June 2023, 20:22   #6
Nightfox
Registered User
 
Nightfox's Avatar
 
Join Date: Apr 2016
Location: Perth, Australia
Posts: 388
Hey yeah man I had looked at your working example and I had made changes as I described in my 2nd last post but couldn't figure out the issue. Maybe it's just something small I missed I dunno. I'm close to the release of my ChatGPT app for Amiga called AmigaGPT. I just need to iron out a few bugs like this scrollbar and change the appearance a bit before I do a proper release. The code is here if you'd like to contribute https://github.com/sacredbanana/AmigaGPT
Nightfox is offline  
Old 29 October 2023, 10:25   #7
Mafi
Registered User
 
Join Date: Jul 2022
Location: Australia
Posts: 49
I’m trying to do pretty much exactly the same thing (but in assembler), I create my objects then call SetAttrsA to set the ICA_TARGET and ICA_MAP attributes. The function returns 0 for both calls, I then open the Window - can see the text editor and the scroller gadgets, but they don’t seem to be “linked”.

Thomas’s C code is what I’m working from as an example; however I have several layout objects under my root Window layout, but other than that I can’t seem to get this working. I also fudged some dummy random addresses for the target pointer to see if something was being called, yes, system did crash!
Mafi is offline  
Old 29 October 2023, 11:13   #8
Minuous
Coder/webmaster/gamer
 
Minuous's Avatar
 
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,641
You could also look at the source code of Report+, AmiArcadia or MCE; they all have this functionality.
Minuous is offline  
Old 21 January 2024, 04:06   #9
Mafi
Registered User
 
Join Date: Jul 2022
Location: Australia
Posts: 49
Ok, finally getting back to this. SetAttrsA and SetGadgetAttrsA work, because I can set other attributes on the gadgets and they take effect. However, with ICA_TARGET and ICA_MAP nothing seems to happen, ICA_TARGET for both text editor and scroller contains the gadget object pointers of each other, ICA_MAP is a pointer to a tag list/mapping per Thomas’s code. Is there anyway to debug ICC at all?

Cheers,
-Matt
Mafi is offline  
Old 26 January 2024, 02:06   #10
Mafi
Registered User
 
Join Date: Jul 2022
Location: Australia
Posts: 49
Looping back here. This is now solved. As there are no assembler include files for most of the Reaction libraries (inc. texteditor and scroller), I've been having to use the C headers to determine what the attribute values should be.

I had:
ScrollerDummy EQU (REACTION_Dummy+$5000)
TextEditorDummy EQU (REACTION_Dummy+$26000)

The problem was with the value for TextEditorDummy, halfway down texteditor.h (after the attributes I was interested in) there is this:

#undef TEXTEDITOR_Dummy
#define TEXTEDITOR_Dummy (0x45000)

Maybe I wrongly assumed that this meant, "from this point forward, the following attributes are offset from this new TEXTEDITOR_Dummy value". Clearly I was wrong, after compiling Thomas's code to assembler, I noticed the mapping files using $45000 as the base for all texteditor attributes. I updated my EQU in my source, and now everything is working perfectly.

Cheers,
-Matt
Mafi is offline  
Old 28 January 2024, 15:29   #11
Nightfox
Registered User
 
Nightfox's Avatar
 
Join Date: Apr 2016
Location: Perth, Australia
Posts: 388
Wow great job! You are the Sherlock of the Amiga world
Nightfox is offline  
Old 01 February 2024, 11:05   #12
Mafi
Registered User
 
Join Date: Jul 2022
Location: Australia
Posts: 49
I’m beginning to wonder if it’s a bug in the 3.2 NDK
Mafi is offline  
Old 08 February 2024, 10:08   #13
boemann
Camilla, AmigaOS Dev.
 
Join Date: Mar 2020
Location: Frederiksberg
Posts: 328
Quote:
Originally Posted by Mafi View Post
#undef TEXTEDITOR_Dummy
#define TEXTEDITOR_Dummy (0x45000)

Maybe I wrongly assumed that this meant, "from this point forward, the following attributes are offset from this new TEXTEDITOR_Dummy value". Clearly I was wrong, after compiling Thomas's code to assembler, I noticed the mapping files using $45000 as the base for all texteditor attributes. I updated my EQU in my source, and now everything is working perfectly.

Cheers,
-Matt
Interesting I assumed the same thing. We better change the ndk to avoid this kind of confusion.

Btw For the future I will only entertain programming questions at our new forum at developer.amigaos3.net
boemann is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with MUI TextEditor xboxown Coders. Blitz Basic 0 13 December 2022 18:10
Is this BOOPSI or GadTools redblade Coders. General 1 14 April 2020 23:04
Sine scroller pmc Coders. Tutorials 95 02 July 2017 16:40
Corkscrew scroller pmc Coders. Tutorials 33 01 September 2010 12:41
TextEditor Oneillsite request.Apps 0 10 January 2006 09:02

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:36.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.13757 seconds with 13 queries