28 May 2023, 06:19 | #1 |
Registered User
Join Date: Apr 2016
Location: Perth, Australia
Posts: 423
|
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); |
28 May 2023, 11:12 | #2 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,040
|
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 |
28 May 2023, 12:12 | #3 |
Registered User
Join Date: Apr 2016
Location: Perth, Australia
Posts: 423
|
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); |
05 June 2023, 18:35 | #4 |
Registered User
Join Date: Apr 2016
Location: Perth, Australia
Posts: 423
|
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 Code:
WINDOW_IDCMPHookBits Code:
IDCMP_IDCMPUPDATE 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; } } |
05 June 2023, 20:11 | #5 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,040
|
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. |
05 June 2023, 20:22 | #6 |
Registered User
Join Date: Apr 2016
Location: Perth, Australia
Posts: 423
|
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
|
29 October 2023, 10:25 | #7 |
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! |
29 October 2023, 11:13 | #8 |
Coder/webmaster/gamer
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,701
|
You could also look at the source code of Report+, AmiArcadia or MCE; they all have this functionality.
|
21 January 2024, 04:06 | #9 |
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 |
26 January 2024, 02:06 | #10 |
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 |
28 January 2024, 15:29 | #11 |
Registered User
Join Date: Apr 2016
Location: Perth, Australia
Posts: 423
|
Wow great job! You are the Sherlock of the Amiga world
|
01 February 2024, 11:05 | #12 |
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
|
08 February 2024, 10:08 | #13 | |
Camilla, AmigaOS Dev.
Join Date: Mar 2020
Location: Frederiksberg
Posts: 336
|
Quote:
Btw For the future I will only entertain programming questions at our new forum at developer.amigaos3.net |
|
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 |
|
|